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
This commit is contained in:
Chayapak 2023-07-28 10:00:11 +07:00
parent e68b3dfc8c
commit 106b55bcc3
2 changed files with 10 additions and 1 deletions

View file

@ -127,7 +127,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
if (currentSong.finished()) { if (currentSong.finished()) {
if (loop == Loop.CURRENT) { if (loop == Loop.CURRENT) {
currentSong.setTime(0); currentSong.loop();
return; return;
} }

View file

@ -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 () { public Note getNextNote () {
if (position >= notes.size()) { if (position >= notes.size()) {
if (bot.music.loop == Loop.OFF) return null; if (bot.music.loop == Loop.OFF) return null;