bot.chat().actionBar() mabe

This commit is contained in:
Chayapak 2023-05-09 13:15:48 +07:00
parent fb0a1a4578
commit 37261fa318
3 changed files with 13 additions and 5 deletions

View file

@ -15,7 +15,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
private final Map<String, BossBar> bossBars = new HashMap<>();
@Getter @Setter private boolean enabled = true;
@Getter @Setter private boolean actionbar = false;
@Getter @Setter private boolean actionBar = false;
@Getter @Setter private String bossBarPrefix = "chomens_bot:";
@Getter @Setter private String textDisplayPrefix = "chomens_bot_";
@ -41,7 +41,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
final String stringifiedComponent = GsonComponentSerializer.gson().serialize(bossBar.name());
if (!actionbar) {
if (!actionBar) {
bot.core().run("minecraft:bossbar add " + bossBarPrefix + name + " \"\"");
bot.core().run("minecraft:bossbar set " + bossBarPrefix + name + " players " + bossBar.players());
bot.core().run("minecraft:bossbar set " + bossBarPrefix + name + " color " + bossBar.color().color);
@ -51,7 +51,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
bot.core().run("minecraft:bossbar set " + bossBarPrefix + name + " name " + stringifiedComponent);
bot.core().run("minecraft:bossbar set " + bossBarPrefix + name + " value " + bossBar.value());
} else {
bot.core().run("minecraft:title " + bossBar.players() + " actionbar " + stringifiedComponent);
bot.chat().actionBar(bossBar.name(), bossBar.players());
}
// is there any way instead of using random?

View file

@ -6,7 +6,6 @@ import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import java.util.concurrent.TimeUnit;
@ -31,7 +30,7 @@ public class BruhifyPlugin {
hue = (hue + increment) % 360;
}
bot.core().run("minecraft:title @a actionbar " + GsonComponentSerializer.gson().serialize(component));
bot.chat().actionBar(component);
startHue = (startHue + increment) % 360;
}, 50, 100, TimeUnit.MILLISECONDS);

View file

@ -261,6 +261,15 @@ public class ChatPlugin extends Bot.Listener {
public void tellraw (Component component) { tellraw(component, "@a"); }
public void actionBar (Component component, String targets) {
if (bot.options().useChat()) return;
bot.core().run("minecraft:title " + targets + " actionbar " + GsonComponentSerializer.gson().serialize(component));
}
public void actionBar (Component component, UUID uuid) { actionBar(component, UUIDUtilities.selector(uuid)); }
public void actionBar (Component component) { actionBar(component, "@a"); }
public void addListener (Listener listener) { listeners.add(listener); }
public static class Listener {