From 106b55bcc3a868ef752c9d4a689dfa6cc4f14a26 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Fri, 28 Jul 2023 10:00:11 +0700 Subject: [PATCH] FIX music nbs looping well not entirely because we still have the loop count but i think i will never implement that because im lazy owo --- .../chayapak/chomens_bot/plugins/MusicPlayerPlugin.java | 2 +- .../land/chipmunk/chayapak/chomens_bot/song/Song.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java index 8fe511c..fc88169 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/MusicPlayerPlugin.java @@ -127,7 +127,7 @@ public class MusicPlayerPlugin extends Bot.Listener { if (currentSong.finished()) { if (loop == Loop.CURRENT) { - currentSong.setTime(0); + currentSong.loop(); return; } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java index c134ead..440d25d 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/song/Song.java @@ -105,6 +105,15 @@ public class Song { } } + public void loop () { + position = 0; + startTime += length - loopPosition; + time -= length - loopPosition; + while (position < notes.size() && notes.get(position).time < loopPosition) { + position++; + } + } + public Note getNextNote () { if (position >= notes.size()) { if (bot.music.loop == Loop.OFF) return null;