From 3f7625895f61d1fb36ac1de28b12d67a17410666 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sat, 10 May 2025 16:10:42 +0700 Subject: [PATCH] fix: hopefully fix the music player racing contest 2025 refactor: change the ordering of variables and things --- build-number.txt | 2 +- .../plugins/MusicPlayerPlugin.java | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/build-number.txt b/build-number.txt index 7d54aa6f..4e8b78e2 100644 --- a/build-number.txt +++ b/build-number.txt @@ -1 +1 @@ -3178 \ No newline at end of file +3179 \ No newline at end of file diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java index 1df9cb41..f951eab8 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/MusicPlayerPlugin.java @@ -64,16 +64,18 @@ public class MusicPlayerPlugin implements Listener { public float volume = 0; public int amplify = 1; + public String instrument = "off"; + public boolean rainbow = false; // nbs easter egg private float rainbowHue = 0F; - public String instrument = "off"; + public BossBarColor bossBarColor = BossBarColor.YELLOW; private int urlLimit = 0; public boolean locked = false; // this can be set through servereval - public BossBarColor bossBarColor = BossBarColor.YELLOW; + private boolean isStopping = false; public String currentLyrics = ""; @@ -139,6 +141,12 @@ public class MusicPlayerPlugin implements Listener { if (currentSong != null) currentSong.play(); } + @Override + public void disconnected (final DisconnectedEvent event) { + if (currentSong != null) currentSong.pause(); // nice. + loaderThread = null; + } + // this needs a separate ticker because we need // the song to be playing without lag private void onMusicTick () { @@ -162,7 +170,10 @@ public class MusicPlayerPlugin implements Listener { currentSong.play(); } - if (!currentSong.finished()) { + if (isStopping) { + currentSong = null; + isStopping = false; + } else if (!currentSong.finished()) { handleLyrics(); BotBossBar bossBar = bot.bossbar.get(BOSS_BAR_NAME); @@ -381,13 +392,7 @@ public class MusicPlayerPlugin implements Listener { public void stopPlaying () { removeBossBar(); - currentSong = null; - } - - @Override - public void disconnected (final DisconnectedEvent event) { - if (currentSong != null) currentSong.pause(); // nice. - loaderThread = null; + isStopping = true; } public void handlePlaying () {