From d805f79d9bb65b4fb56a8adeedd55f1de002a95f Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 15 May 2019 15:52:07 -0400 Subject: [PATCH] Try to unbreak ViaVersion a little bit. --- .../connection/client/ConnectedPlayer.java | 12 ++++------- .../protocol/util/PluginMessageUtil.java | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index d8c7ee290..d27e21862 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -658,17 +658,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { public boolean canForwardPluginMessage(ProtocolVersion version, PluginMessage message) { boolean minecraftOrFmlMessage; - // We should _always_ pass on new channels the server wishes to register (or unregister) with - // us. - if (PluginMessageUtil.isRegister(message) || PluginMessageUtil.isUnregister(message)) { - return true; - } - // By default, all internal Minecraft and Forge channels are forwarded from the server. if (version.compareTo(ProtocolVersion.MINECRAFT_1_12_2) <= 0) { String channel = message.getChannel(); - minecraftOrFmlMessage = channel.startsWith("MC|") || channel - .startsWith(LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL); + minecraftOrFmlMessage = channel.startsWith("MC|") + || channel.startsWith(LegacyForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL) + || PluginMessageUtil.isLegacyRegister(message) + || PluginMessageUtil.isLegacyUnregister(message); } else { minecraftOrFmlMessage = message.getChannel().startsWith("minecraft:"); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtil.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtil.java index c03019606..37b4cc876 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtil.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/PluginMessageUtil.java @@ -61,6 +61,27 @@ public class PluginMessageUtil { .equals(UNREGISTER_CHANNEL); } + /** + * Determines whether or not this plugin message is a legacy (<1.13) registration plugin message. + * @param message the plugin message + * @return whether this is a legacy register message + */ + public static boolean isLegacyRegister(PluginMessage message) { + checkNotNull(message, "message"); + return message.getChannel().equals(REGISTER_CHANNEL_LEGACY); + } + + /** + * Determines whether or not this plugin message is a legacy (<1.13) unregistration plugin + * message. + * @param message the plugin message + * @return whether this is a legacy unregister message + */ + public static boolean isLegacyUnregister(PluginMessage message) { + checkNotNull(message, "message"); + return message.getChannel().equals(UNREGISTER_CHANNEL_LEGACY); + } + /** * Fetches all the channels in a register or unregister plugin message. * @param message the message to get the channels from