[BossBar] Forward UUID to platforms to prepare for 26.1 changes

This commit is contained in:
NEZNAMY committed 2026-03-31 17:02:28 +02:00
1 parent 87c15f7611
commit 2beb9563bb
9 files changed
+27 -11

No files matched your search

@@ -12,6 +12,8 @@ import org.bukkit.Bukkit;
import org.bukkit.boss.BossBar;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* BossBar for 1.9+ servers where Bukkit API is used. If ViaVersion is used
* to allow 1.8 players, it will handle the entity and teleporting by itself.
@@ -32,7 +34,7 @@ public class BukkitBossBar extends SafeBossBar<BossBar> {
@Override
@NotNull
public BossBar constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
public BossBar constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
BossBar bar = Bukkit.createBossBar(
player.getPlatform().toBukkitFormat(title),
org.bukkit.boss.BarColor.valueOf(color.name()),
@@ -12,6 +12,8 @@ import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.shared.platform.decorators.SafeBossBar;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Handler for 1.9+ players on 1.8 server using ViaVersion API.
*/
@@ -27,7 +29,7 @@ public class ViaBossBar extends SafeBossBar<BossBar> {
@Override
@NotNull
public BossBar constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
public BossBar constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
return Via.getAPI().legacyAPI().createLegacyBossBar(
title.toLegacyText(),
progress,
@@ -24,8 +24,8 @@ public class BungeeBossBar extends SafeBossBar<UUID> {
@Override
@NotNull
public UUID constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
return UUID.randomUUID();
public UUID constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
return id;
}
@Override
@@ -10,6 +10,8 @@ import net.minecraft.world.BossEvent.BossBarColor;
import net.minecraft.world.BossEvent.BossBarOverlay;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* BossBar implementation for Fabric using packets.
*/
@@ -22,7 +24,7 @@ public class FabricBossBar extends SafeBossBar<ServerBossEvent> {
@Override
@NotNull
public ServerBossEvent constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
public ServerBossEvent constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
ServerBossEvent bar = new ServerBossEvent(
title.convert(),
BossBarColor.valueOf(color.name()),
@@ -10,6 +10,8 @@ import net.minecraft.world.BossEvent.BossBarColor;
import net.minecraft.world.BossEvent.BossBarOverlay;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* BossBar implementation for Forge using packets.
*/
@@ -22,7 +24,7 @@ public class ForgeBossBar extends SafeBossBar<ServerBossEvent> {
@Override
@NotNull
public ServerBossEvent constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
public ServerBossEvent constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
ServerBossEvent bar = new ServerBossEvent(
title.convert(),
BossBarColor.valueOf(color.name()),
@@ -10,6 +10,8 @@ import net.minecraft.world.BossEvent.BossBarColor;
import net.minecraft.world.BossEvent.BossBarOverlay;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* BossBar implementation for NeoForge using packets.
*/
@@ -22,7 +24,7 @@ public class NeoForgeBossBar extends SafeBossBar<ServerBossEvent> {
@Override
@NotNull
public ServerBossEvent constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
public ServerBossEvent constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
ServerBossEvent bar = new ServerBossEvent(
title.convert(),
BossBarColor.valueOf(color.name()),
@@ -35,7 +35,7 @@ public abstract class SafeBossBar<T> implements BossBar {
@Override
public synchronized void create(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
BossBarInfo bar = new BossBarInfo(title, progress, color, style, constructBossBar(title, progress, color, style));
BossBarInfo bar = new BossBarInfo(title, progress, color, style, constructBossBar(id, title, progress, color, style));
bossBars.put(id, bar);
if (frozen) return;
show(bar);
@@ -132,6 +132,8 @@ public abstract class SafeBossBar<T> implements BossBar {
/**
* Constructs platform's BossBar object with given parameters.
*
* @param id
* BossBar UUID (if configurable by platform)
* @param title
* BossBar title
* @param progress
@@ -143,7 +145,7 @@ public abstract class SafeBossBar<T> implements BossBar {
* @return Platform's BossBar with given data
*/
@NotNull
public abstract T constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style);
public abstract T constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style);
/**
* Shows BossBar to the player.
@@ -14,6 +14,8 @@ import net.kyori.adventure.bossbar.BossBar.Color;
import net.kyori.adventure.bossbar.BossBar.Overlay;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Shared BossBar implementation using Adventure API.
*/
@@ -29,7 +31,7 @@ public class AdventureBossBar extends SafeBossBar<BossBar> {
@Override
@NotNull
public BossBar constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
public BossBar constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
return BossBar.bossBar(title.toAdventure(), progress, Color.valueOf(color.name()), Overlay.valueOf(style.name()));
}
@@ -6,6 +6,8 @@ import me.neznamy.tab.shared.chat.component.TabComponent;
import me.neznamy.tab.shared.platform.decorators.SafeBossBar;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
/**
* Dummy implementation when no suitable one is available.
*/
@@ -13,7 +15,7 @@ public class DummyBossBar extends SafeBossBar<Object> {
@Override
@NotNull
public Object constructBossBar(@NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
public Object constructBossBar(@NotNull UUID id, @NotNull TabComponent title, float progress, @NotNull BarColor color, @NotNull BarStyle style) {
return new Object();
}