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