From cb4af91279bfe904498db4e1e3122ba4297941e9 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:26:28 +0700 Subject: [PATCH] support daycore i hate daycore but most people like them for some reason nightcore is just classic and nostalgic --- .../chayapak/chomens_bot/data/BotBossBar.java | 2 +- .../plugins/BossbarManagerPlugin.java | 4 ++-- .../plugins/MusicPlayerPlugin.java | 20 ++++++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/BotBossBar.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/BotBossBar.java index b2f0ca8..36abc61 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/data/BotBossBar.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/data/BotBossBar.java @@ -83,7 +83,7 @@ public class BotBossBar extends BossBar { if (bot.bossbar.actionBar) return; - bot.core.run("minecraft:bossbar set " + id + " color " + (color == BossBarColor.LIME ? "green" : color.name().toLowerCase())); + bot.core.run("minecraft:bossbar set " + id + " color " + (color == BossBarColor.LIME ? "green" : (color == BossBarColor.CYAN ? "blue" : color.name().toLowerCase()))); } public String players() { diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java index c03a45c..80d0574 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/BossbarManagerPlugin.java @@ -42,7 +42,7 @@ public class BossbarManagerPlugin extends Bot.Listener { } }); - bot.executor.scheduleAtFixedRate(this::check, 0, 500, TimeUnit.MILLISECONDS); + bot.executor.scheduleAtFixedRate(this::check, 0, 600, TimeUnit.MILLISECONDS); } @Override @@ -211,7 +211,7 @@ public class BossbarManagerPlugin extends Bot.Listener { bot.core.run("minecraft:bossbar add " + name + " " + stringifiedName); bot.core.run(prefix + "players " + bossBar.players()); - bot.core.run(prefix + "color " + (bossBar.color == BossBarColor.LIME ? "green" : bossBar.color.name().toLowerCase())); + bot.core.run(prefix + "color " + (bossBar.color == BossBarColor.LIME ? "green" : (bossBar.color == BossBarColor.CYAN ? "blue" : bossBar.color.name().toLowerCase()))); bot.core.run(prefix + "visible " + bossBar.visible()); bot.core.run(prefix + "style " + division); bot.core.run(prefix + "max " + bossBar.max()); 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 88248f7..6f9b57b 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 @@ -59,6 +59,8 @@ public class MusicPlayerPlugin extends Bot.Listener { private final String bossbarName = "music"; + public BossBarColor bossBarColor; + public MusicPlayerPlugin (Bot bot) { this.bot = bot; bot.addListener(this); @@ -139,7 +141,7 @@ public class MusicPlayerPlugin extends Bot.Listener { if (bot.bossbar.enabled && bot.options.useCore) { bossBar.setTitle(generateBossbar()); - bossBar.setColor(pitch > 0 ? BossBarColor.PURPLE : BossBarColor.YELLOW); + bossBar.setColor(bossBarColor); bossBar.setValue((int) Math.floor(((double) currentSong.time / 1000) * speed)); bossBar.setMax((long) ((currentSong.length / 1000) * speed)); } @@ -211,7 +213,7 @@ public class MusicPlayerPlugin extends Bot.Listener { final BotBossBar bossBar = new BotBossBar( Component.empty(), BOTH_SELECTOR, - BossBarColor.WHITE, + BossBarColor.LIME, BossBarDivision.NONE, true, (int) currentSong.length / 1000, @@ -229,8 +231,20 @@ public class MusicPlayerPlugin extends Bot.Listener { } public Component generateBossbar () { + NamedTextColor namedTextColor; + if (pitch > 0) { + namedTextColor = NamedTextColor.LIGHT_PURPLE; + bossBarColor = BossBarColor.PURPLE; + } else if (pitch < 0) { + namedTextColor = NamedTextColor.AQUA; + bossBarColor = BossBarColor.CYAN; + } else { + namedTextColor = NamedTextColor.GREEN; + bossBarColor = BossBarColor.YELLOW; + } + Component component = Component.empty() - .append(Component.empty().append(Component.text(currentSong.name)).color(pitch > 0 ? NamedTextColor.LIGHT_PURPLE : NamedTextColor.GREEN)) + .append(Component.empty().append(Component.text(currentSong.name)).color(namedTextColor)) .append(Component.text(" | ").color(NamedTextColor.DARK_GRAY)) .append( Component