3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Update for breaking Adventure boss bar changes

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-07-30 20:16:20 -04:00
Ursprung e3a95b4783
Commit a6964bd31c
2 geänderte Dateien mit 14 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -40,7 +40,7 @@ import com.velocitypowered.proxy.server.ServerMap;
import com.velocitypowered.proxy.util.AddressUtil; import com.velocitypowered.proxy.util.AddressUtil;
import com.velocitypowered.proxy.util.EncryptionUtils; import com.velocitypowered.proxy.util.EncryptionUtils;
import com.velocitypowered.proxy.util.VelocityChannelRegistrar; 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.bossbar.VelocityBossBar;
import com.velocitypowered.proxy.util.ratelimit.Ratelimiter; import com.velocitypowered.proxy.util.ratelimit.Ratelimiter;
import com.velocitypowered.proxy.util.ratelimit.Ratelimiters; 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 final AtomicBoolean shutdownInProgress = new AtomicBoolean(false);
private boolean shutdown = false; private boolean shutdown = false;
private final VelocityPluginManager pluginManager; private final VelocityPluginManager pluginManager;
private final BossBarManager bossBarManager; private final AdventureBossBarManager bossBarManager;
private final Map<UUID, ConnectedPlayer> connectionsByUuid = new ConcurrentHashMap<>(); private final Map<UUID, ConnectedPlayer> connectionsByUuid = new ConcurrentHashMap<>();
private final Map<String, ConnectedPlayer> connectionsByName = new ConcurrentHashMap<>(); private final Map<String, ConnectedPlayer> connectionsByName = new ConcurrentHashMap<>();
@ -131,7 +131,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
cm = new ConnectionManager(this); cm = new ConnectionManager(this);
servers = new ServerMap(this); servers = new ServerMap(this);
this.options = options; this.options = options;
this.bossBarManager = new BossBarManager(); this.bossBarManager = new AdventureBossBarManager();
} }
public KeyPair getServerKeyPair() { public KeyPair getServerKeyPair() {
@ -626,7 +626,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
return audiences; return audiences;
} }
public BossBarManager getBossBarManager() { public AdventureBossBarManager getBossBarManager() {
return bossBarManager; return bossBarManager;
} }

Datei anzeigen

@ -21,7 +21,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
/** /**
* Manages all boss bars known to the proxy. * Manages all boss bars known to the proxy.
*/ */
public class BossBarManager implements BossBar.Listener { public class AdventureBossBarManager implements BossBar.Listener {
private static final Enum2IntMap<Color> COLORS_TO_PROTOCOL = private static final Enum2IntMap<Color> COLORS_TO_PROTOCOL =
new Enum2IntMap.Builder<>(Color.class) new Enum2IntMap.Builder<>(Color.class)
.put(Color.PINK, 0) .put(Color.PINK, 0)
@ -48,7 +48,7 @@ public class BossBarManager implements BossBar.Listener {
.build(); .build();
private final Map<BossBar, BossBarHolder> bars; private final Map<BossBar, BossBarHolder> bars;
public BossBarManager() { public AdventureBossBarManager() {
this.bars = new MapMaker().weakKeys().makeMap(); this.bars = new MapMaker().weakKeys().makeMap();
} }
@ -160,13 +160,13 @@ public class BossBarManager implements BossBar.Listener {
} }
@Override @Override
public void bossBarFlagsChanged(@NonNull BossBar bar, @NonNull Set<Flag> oldFlags, public void bossBarFlagsChanged(@NonNull BossBar bar, @NonNull Set<Flag> added,
@NonNull Set<Flag> newFlags) { @NonNull Set<Flag> removed) {
BossBarHolder holder = this.getHandler(bar); BossBarHolder holder = this.getHandler(bar);
if (holder == null) { if (holder == null) {
return; 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) { for (ConnectedPlayer player : holder.subscribers) {
player.getConnection().write(packet); player.getConnection().write(packet);
} }
@ -184,7 +184,7 @@ public class BossBarManager implements BossBar.Listener {
} }
void register() { void register() {
registrationOnce.run(() -> this.bar.addListener(BossBarManager.this)); registrationOnce.run(() -> this.bar.addListener(AdventureBossBarManager.this));
} }
com.velocitypowered.proxy.protocol.packet.BossBar createRemovePacket() { com.velocitypowered.proxy.protocol.packet.BossBar createRemovePacket() {
@ -233,6 +233,10 @@ public class BossBarManager implements BossBar.Listener {
return packet; return packet;
} }
com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate() {
return createFlagsUpdate(bar.flags());
}
com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate(Set<Flag> newFlags) { com.velocitypowered.proxy.protocol.packet.BossBar createFlagsUpdate(Set<Flag> newFlags) {
com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered com.velocitypowered.proxy.protocol.packet.BossBar packet = new com.velocitypowered
.proxy.protocol.packet.BossBar(); .proxy.protocol.packet.BossBar();