-
I have following code: public static void builderBar(Player player) {
Integer points = player.getInstance().getTag(Tags.points);
BossBarManager manager = new BossBarManager();
Collection<BossBar> playerBars = manager.getPlayerBossBars(player);
if (playerBars.isEmpty()) {
System.out.println("First bar is not empty");
BossBar firstBar = playerBars.iterator().next();
firstBar.name(Component.text("World bits: " + points));
firstBar.progress(points / 100);
} else {
BossBar bar = BossBar.bossBar(Component.text("World bits: " + points), 0.6f, BossBar.Color.GREEN, BossBar.Overlay.PROGRESS);
player.showBossBar(bar);
}
} Why it does no working and I could not get if player have bossbar? |
Beta Was this translation helpful? Give feedback.
Answered by
BL19
May 30, 2024
Replies: 1 comment 1 reply
-
It seems like you are creating a new |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AntonIXO
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems like you are creating a new
BossBarManager
every time and I guess that's why it's not working. I haven't tried this, but my guess is that using MinecraftServer#getBossBarManager() instead ofnew BossBarManager()
would solve it.