mirror of
https://github.com/SPAWNRYS-ban/FUCK-CustomDiscs.git
synced 2025-12-11 22:09:43 +05:00
Finished recode
This commit is contained in:
@@ -103,6 +103,7 @@ public class PlayerManager {
|
|||||||
if (playerMap.containsValue(playerReference)) {
|
if (playerMap.containsValue(playerReference)) {
|
||||||
playerMap.remove(id);
|
playerMap.remove(id);
|
||||||
}
|
}
|
||||||
|
System.out.println(playerMap);
|
||||||
});
|
});
|
||||||
synchronized (stopped) {
|
synchronized (stopped) {
|
||||||
if (!stopped.get()) {
|
if (!stopped.get()) {
|
||||||
@@ -160,7 +161,9 @@ public class PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static short[] readSoundFile(AudioInputStream inputStream) throws IOException {
|
private static short[] readSoundFile(AudioInputStream inputStream) throws IOException {
|
||||||
return VoicePlugin.voicechatApi.getAudioConverter().bytesToShorts(getAudioPacket(inputStream));
|
byte[] audioPacket = getAudioPacket(inputStream);
|
||||||
|
if (audioPacket == null) return null;
|
||||||
|
return VoicePlugin.voicechatApi.getAudioConverter().bytesToShorts(audioPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] getAudioPacket(AudioInputStream inputStream) throws IOException {
|
private static byte[] getAudioPacket(AudioInputStream inputStream) throws IOException {
|
||||||
@@ -184,6 +187,8 @@ public class PlayerManager {
|
|||||||
|
|
||||||
private static byte[] adjustVolume(byte[] audioSamples, double volume) {
|
private static byte[] adjustVolume(byte[] audioSamples, double volume) {
|
||||||
|
|
||||||
|
if (audioSamples == null) return null;
|
||||||
|
|
||||||
if (volume > 1d || volume < 0d) {
|
if (volume > 1d || volume < 0d) {
|
||||||
CustomDiscs.getInstance().getLogger().info("Error: The volume must be between 0 and 1 in the config!");
|
CustomDiscs.getInstance().getLogger().info("Error: The volume must be between 0 and 1 in the config!");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class JukeBox implements Listener{
|
|||||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null || event.getItem() == null || event.getItem().getItemMeta() == null || block == null) return;
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock() == null || event.getItem() == null || event.getItem().getItemMeta() == null || block == null) return;
|
||||||
if (event.getClickedBlock().getType() != Material.JUKEBOX) return;
|
if (event.getClickedBlock().getType() != Material.JUKEBOX) return;
|
||||||
|
|
||||||
if (isCustomMusicDisc(event) && !jukeboxContainsDisc(block)) {
|
if (isCustomMusicDisc(event.getItem()) && !jukeboxContainsDisc(block)) {
|
||||||
|
|
||||||
ItemMeta discMeta = event.getItem().getItemMeta();
|
ItemMeta discMeta = event.getItem().getItemMeta();
|
||||||
String soundFileName = discMeta.getPersistentDataContainer().get(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
String soundFileName = discMeta.getPersistentDataContainer().get(new NamespacedKey(customDiscs, "customdisc"), PersistentDataType.STRING);
|
||||||
@@ -120,6 +120,8 @@ public class JukeBox implements Listener{
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
if (block.getType() != Material.JUKEBOX) return;
|
if (block.getType() != Material.JUKEBOX) return;
|
||||||
|
Jukebox jukebox = (Jukebox) block.getState();
|
||||||
|
if (!isCustomMusicDisc(jukebox.getRecord())) return;
|
||||||
|
|
||||||
stopDisc(block);
|
stopDisc(block);
|
||||||
}
|
}
|
||||||
@@ -129,6 +131,8 @@ public class JukeBox implements Listener{
|
|||||||
|
|
||||||
for (Block explodedBlock : event.blockList()) {
|
for (Block explodedBlock : event.blockList()) {
|
||||||
if (explodedBlock.getType() == Material.JUKEBOX) {
|
if (explodedBlock.getType() == Material.JUKEBOX) {
|
||||||
|
Jukebox jukebox = (Jukebox) explodedBlock.getState();
|
||||||
|
if (!isCustomMusicDisc(jukebox.getRecord())) return;
|
||||||
stopDisc(explodedBlock);
|
stopDisc(explodedBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,9 +144,9 @@ public class JukeBox implements Listener{
|
|||||||
return jukebox.getRecord().getType() != Material.AIR;
|
return jukebox.getRecord().getType() != Material.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCustomMusicDisc(PlayerInteractEvent e) {
|
public boolean isCustomMusicDisc(ItemStack itemStack) {
|
||||||
if (e.getItem()==null) return false;
|
if (itemStack==null) return false;
|
||||||
return e.getItem().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customdisc"));
|
return itemStack.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(customDiscs, "customdisc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopDisc(Block block) {
|
private void stopDisc(Block block) {
|
||||||
|
|||||||
Reference in New Issue
Block a user