From ad050cf940f76b099c396182681866efabf77acc Mon Sep 17 00:00:00 2001 From: Navoei Date: Tue, 12 Jul 2022 20:44:52 -0500 Subject: [PATCH] Bugfix Patched a bug where players could dupe discs if the file is not found whent he player inserts a disc into a jukebox. --- .../java/me/Navoei/customdiscsplugin/event/JukeBox.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java b/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java index fa26070..964ca24 100644 --- a/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java +++ b/src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java @@ -65,9 +65,6 @@ public class JukeBox implements Listener { event.setCancelled(true); - container.set(key, PersistentDataType.BYTE_ARRAY, event.getItem().serializeAsBytes()); - tileState.update(); - Component soundFileNameComponent = Objects.requireNonNull(event.getItem().getItemMeta().lore()).get(1).asComponent(); String soundFileName = PlainTextComponentSerializer.plainText().serialize(soundFileNameComponent); @@ -86,6 +83,10 @@ public class JukeBox implements Listener { AudioPlayer audioPlayer = VoicePlugin.voicechatServerApi.createAudioPlayer(audioChannel, VoicePlugin.voicechatApi.createEncoder(), readSoundFile(soundFilePath)); playerMap.put(id, audioPlayer); audioPlayer.startPlaying(); + + //set the persistent data container and remove the item from the player's hand + container.set(key, PersistentDataType.BYTE_ARRAY, event.getItem().serializeAsBytes()); + tileState.update(); player.getInventory().setItem(Objects.requireNonNull(event.getHand()), null); //Send Player Action Bar @@ -93,7 +94,6 @@ public class JukeBox implements Listener { .content("Now Playing: " + songName) .color(NamedTextColor.GOLD) .build(); - player.sendActionBar(customLoreSong.asComponent()); } catch (Exception e) {