From e49a05fd8c4f71a731aafdc8c05d62162e82b3bd Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Sun, 15 Oct 2023 12:06:32 +0700 Subject: [PATCH] bring back text displays bossbar thing --- .../chipmunk/chayapak/chomens_bot/data/BotBossBar.java | 7 ++++++- .../chayapak/chomens_bot/plugins/BossbarManagerPlugin.java | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 36abc61..f90d0b2 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 @@ -18,6 +18,7 @@ public class BotBossBar extends BossBar { private final Bot bot; + public String onlyName; public String id; private String players; @@ -63,7 +64,11 @@ public class BotBossBar extends BossBar { this.title = title; - bot.core.run("minecraft:bossbar set " + id + " name " + GsonComponentSerializer.gson().serialize(title)); + final String serialized = GsonComponentSerializer.gson().serialize(title); + + bot.core.run("minecraft:bossbar set " + id + " name " + serialized); + + if (!bot.core.hasRateLimit()) bot.core.run("minecraft:execute as @e[type=minecraft:text_display,tag=" + bot.config.bossBarNamespace + "_" + onlyName + "] run data modify entity @s text set value '" + serialized.replace("\\", "\\\\" + "'").replace("'", "\\'") + "'"); } public BossBarColor color(BossBarColor color) { 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 99b8bd6..addc537 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 @@ -84,6 +84,7 @@ public class BossbarManagerPlugin extends Bot.Listener { ); bossBars.get(packet.getUuid()).id = bossBar.id; + bossBars.get(packet.getUuid()).onlyName = bossBar.onlyName; bossBars.get(packet.getUuid()).uuid = packet.getUuid(); newBossBar.setTitle(bossBar.title); @@ -183,6 +184,8 @@ public class BossbarManagerPlugin extends Bot.Listener { public void add (String name, BotBossBar bossBar) { if (!enabled || !bot.options.useCore) return; + bossBar.onlyName = name; + bossBar.id = bossBarPrefix + name; bossBars.put(bossBar.uuid, bossBar);