From a6964bd31cb3a39d5578ed5f055e6b252b956fe5 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 30 Jul 2020 20:16:20 -0400 Subject: [PATCH] Update for breaking Adventure boss bar changes --- .../velocitypowered/proxy/VelocityServer.java | 8 ++++---- ...Manager.java => AdventureBossBarManager.java} | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) rename proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/{BossBarManager.java => AdventureBossBarManager.java} (96%) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 4372e5604..ea0c3c0a1 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -40,7 +40,7 @@ import com.velocitypowered.proxy.server.ServerMap; import com.velocitypowered.proxy.util.AddressUtil; import com.velocitypowered.proxy.util.EncryptionUtils; import com.velocitypowered.proxy.util.VelocityChannelRegistrar; -import com.velocitypowered.proxy.util.bossbar.BossBarManager; +import com.velocitypowered.proxy.util.bossbar.AdventureBossBarManager; import com.velocitypowered.proxy.util.bossbar.VelocityBossBar; import com.velocitypowered.proxy.util.ratelimit.Ratelimiter; import com.velocitypowered.proxy.util.ratelimit.Ratelimiters; @@ -112,7 +112,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { private final AtomicBoolean shutdownInProgress = new AtomicBoolean(false); private boolean shutdown = false; private final VelocityPluginManager pluginManager; - private final BossBarManager bossBarManager; + private final AdventureBossBarManager bossBarManager; private final Map connectionsByUuid = new ConcurrentHashMap<>(); private final Map connectionsByName = new ConcurrentHashMap<>(); @@ -131,7 +131,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { cm = new ConnectionManager(this); servers = new ServerMap(this); this.options = options; - this.bossBarManager = new BossBarManager(); + this.bossBarManager = new AdventureBossBarManager(); } public KeyPair getServerKeyPair() { @@ -626,7 +626,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { return audiences; } - public BossBarManager getBossBarManager() { + public AdventureBossBarManager getBossBarManager() { return bossBarManager; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/BossBarManager.java b/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/AdventureBossBarManager.java similarity index 96% rename from proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/BossBarManager.java rename to proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/AdventureBossBarManager.java index 223c5ed25..7552e2202 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/BossBarManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/bossbar/AdventureBossBarManager.java @@ -21,7 +21,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; /** * Manages all boss bars known to the proxy. */ -public class BossBarManager implements BossBar.Listener { +public class AdventureBossBarManager implements BossBar.Listener { private static final Enum2IntMap COLORS_TO_PROTOCOL = new Enum2IntMap.Builder<>(Color.class) .put(Color.PINK, 0) @@ -48,7 +48,7 @@ public class BossBarManager implements BossBar.Listener { .build(); private final Map bars; - public BossBarManager() { + public AdventureBossBarManager() { this.bars = new MapMaker().weakKeys().makeMap(); } @@ -160,13 +160,13 @@ public class BossBarManager implements BossBar.Listener { } @Override - public void bossBarFlagsChanged(@NonNull BossBar bar, @NonNull Set oldFlags, - @NonNull Set newFlags) { + public void bossBarFlagsChanged(@NonNull BossBar bar, @NonNull Set added, + @NonNull Set removed) { BossBarHolder holder = this.getHandler(bar); if (holder == null) { return; } - com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createFlagsUpdate(newFlags); + com.velocitypowered.proxy.protocol.packet.BossBar packet = holder.createFlagsUpdate(); for (ConnectedPlayer player : holder.subscribers) { player.getConnection().write(packet); } @@ -184,7 +184,7 @@ public class BossBarManager implements BossBar.Listener { } void register() { - registrationOnce.run(() -> this.bar.addListener(BossBarManager.this)); + registrationOnce.run(() -> this.bar.addListener(AdventureBossBarManager.this)); } com.velocitypowered.proxy.protocol.packet.BossBar createRemovePacket() { @@ -233,6 +233,10 @@ public class BossBarManager implements BossBar.Listener { return packet; } + com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate() { + return createFlagsUpdate(bar.flags()); + } + com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate(Set newFlags) { com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered .proxy.protocol.packet.BossBar();