From 74afcee9bae688438a5c3f049bb79e1e7321594c Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Fri, 10 May 2019 04:53:57 -0400 Subject: [PATCH] Suspect this is the fix to #203, but I'm unsure --- .../connection/backend/TransitionSessionHandler.java | 9 +++++++++ .../proxy/util/collect/CappedCollectionTest.java | 3 +++ 2 files changed, 12 insertions(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java index 302c70449..07a06c89e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/TransitionSessionHandler.java @@ -19,6 +19,7 @@ import com.velocitypowered.proxy.protocol.packet.Disconnect; import com.velocitypowered.proxy.protocol.packet.JoinGame; import com.velocitypowered.proxy.protocol.packet.KeepAlive; import com.velocitypowered.proxy.protocol.packet.PluginMessage; +import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; import java.io.IOException; import java.util.Collection; import java.util.concurrent.CompletableFuture; @@ -134,6 +135,14 @@ public class TransitionSessionHandler implements MinecraftSessionHandler { return true; } + // We need to specially handle REGISTER and UNREGISTER packets. Later on, we'll write them to + // the client. + if (PluginMessageUtil.isRegister(packet)) { + serverConn.getPlayer().getKnownChannels().addAll(PluginMessageUtil.getChannels(packet)); + } else if (PluginMessageUtil.isUnregister(packet)) { + serverConn.getPlayer().getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet)); + } + // We always need to handle plugin messages, for Forge compatibility. if (serverConn.getPhase().handle(serverConn, serverConn.getPlayer(), packet)) { // Handled, but check the server connection phase. diff --git a/proxy/src/test/java/com/velocitypowered/proxy/util/collect/CappedCollectionTest.java b/proxy/src/test/java/com/velocitypowered/proxy/util/collect/CappedCollectionTest.java index f6fbcd919..d9bcab45d 100644 --- a/proxy/src/test/java/com/velocitypowered/proxy/util/collect/CappedCollectionTest.java +++ b/proxy/src/test/java/com/velocitypowered/proxy/util/collect/CappedCollectionTest.java @@ -44,6 +44,9 @@ class CappedCollectionTest { assertTrue(coll.addAll(doesFill2), "did not add items"); assertThrows(IllegalStateException.class, () -> coll.addAll(overfill), "items added to collection although it is too full"); + + assertFalse(coll.addAll(doesFill1), "added items?!?"); + assertEquals(3, coll.size(), "collection grew in size unexpectedly"); } } \ No newline at end of file