actually fix music even more

This commit is contained in:
Chayapak 2023-04-05 17:42:49 +07:00
parent 2a92a02dd9
commit a957a281b1

View file

@ -104,15 +104,7 @@ public class MusicPlayerPlugin extends SessionAdapter {
if (currentSong == null) { if (currentSong == null) {
if (songQueue.size() == 0) return; if (songQueue.size() == 0) return;
bot.bossbar().add(bossbarName, new BossBar( addBossBar();
Component.empty(),
BossBarColor.WHITE,
0,
"",
BossBarStyle.PROGRESS,
0,
false
));
currentSong = songQueue.get(0); // songQueue.poll(); currentSong = songQueue.get(0); // songQueue.poll();
bot.chat().tellraw(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.GOLD))); bot.chat().tellraw(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.GOLD)));
@ -122,7 +114,9 @@ public class MusicPlayerPlugin extends SessionAdapter {
if (currentSong.paused && ticksUntilPausedBossbar-- < 0) return; if (currentSong.paused && ticksUntilPausedBossbar-- < 0) return;
else ticksUntilPausedBossbar = 20; else ticksUntilPausedBossbar = 20;
final BossBar bossBar = bot.bossbar().get(bossbarName); BossBar bossBar = bot.bossbar().get(bossbarName);
if (bossBar == null) bossBar = addBossBar();
bossBar.players(SELECTOR); bossBar.players(SELECTOR);
bossBar.name(generateBossbar()); bossBar.name(generateBossbar());
@ -152,7 +146,7 @@ public class MusicPlayerPlugin extends SessionAdapter {
if (songQueue.size() == 0) { if (songQueue.size() == 0) {
stopPlaying(); stopPlaying();
removeBossbar(); removeBossBar();
bot.chat().tellraw(Component.text("Finished playing every song in the queue")); bot.chat().tellraw(Component.text("Finished playing every song in the queue"));
return; return;
} }
@ -182,7 +176,23 @@ public class MusicPlayerPlugin extends SessionAdapter {
currentSong.play(); currentSong.play();
} }
public void removeBossbar () { public BossBar addBossBar () {
final BossBar bossBar = new BossBar(
Component.empty(),
BossBarColor.WHITE,
0,
"",
BossBarStyle.PROGRESS,
0,
false
);
bot.bossbar().add(bossbarName, bossBar);
return bossBar;
}
public void removeBossBar() {
bot.bossbar().remove(bossbarName); bot.bossbar().remove(bossbarName);
} }
@ -232,7 +242,7 @@ public class MusicPlayerPlugin extends SessionAdapter {
public void stopPlaying () { public void stopPlaying () {
currentSong = null; currentSong = null;
removeBossbar(); removeBossBar();
} }
@Override @Override