diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index 03f3679e6..12fcd6665 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -6,7 +6,7 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.client.ClientPlaySessionHandler; -import com.velocitypowered.proxy.connection.forge.ForgeUtil; +import com.velocitypowered.proxy.connection.forge.ForgeConstants; import com.velocitypowered.proxy.connection.util.ConnectionMessages; import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.ProtocolConstants; @@ -84,7 +84,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { return true; } - if (!serverConn.hasCompletedJoin() && packet.getChannel().equals(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL)) { + if (!serverConn.hasCompletedJoin() && packet.getChannel().equals(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) { if (!serverConn.isLegacyForge()) { serverConn.setLegacyForge(true); @@ -173,7 +173,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { boolean isMCOrFMLMessage; if (serverConn.getConnection().getProtocolVersion() <= ProtocolConstants.MINECRAFT_1_12_2) { String channel = message.getChannel(); - isMCOrFMLMessage = channel.startsWith("MC|") || channel.startsWith(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL); + isMCOrFMLMessage = channel.startsWith("MC|") || channel.startsWith(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL); } else { isMCOrFMLMessage = message.getChannel().startsWith("minecraft:"); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 707db0f78..90b9a9555 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -7,6 +7,7 @@ import com.velocitypowered.api.util.ModInfo; import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; +import com.velocitypowered.proxy.connection.forge.ForgeConstants; import com.velocitypowered.proxy.connection.forge.ForgeUtil; import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.ProtocolConstants; @@ -144,7 +145,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { } else if (PluginMessageUtil.isMCBrand(packet)) { player.getConnectedServer().getConnection().write(PluginMessageUtil.rewriteMCBrand(packet)); } else if (player.getConnectedServer().isLegacyForge() && !player.getConnectedServer().hasCompletedJoin()) { - if (packet.getChannel().equals(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL)) { + if (packet.getChannel().equals(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) { if (!player.getModInfo().isPresent()) { ForgeUtil.readModList(packet).ifPresent(mods -> player.setModInfo(new ModInfo("FML", mods))); } 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 63f53e3b6..c187d5d9b 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 @@ -26,7 +26,7 @@ import com.velocitypowered.proxy.VelocityServer; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation; import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; -import com.velocitypowered.proxy.connection.forge.ForgeUtil; +import com.velocitypowered.proxy.connection.forge.ForgeConstants; import com.velocitypowered.proxy.connection.util.ConnectionMessages; import com.velocitypowered.proxy.connection.util.ConnectionRequestResults; import com.velocitypowered.proxy.protocol.ProtocolConstants; @@ -400,8 +400,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { public void sendLegacyForgeHandshakeResetPacket() { if (connection.canSendLegacyFMLResetPacket()) { PluginMessage resetPacket = new PluginMessage(); - resetPacket.setChannel(ForgeUtil.FORGE_LEGACY_HANDSHAKE_CHANNEL); - resetPacket.setData(ForgeUtil.FORGE_LEGACY_HANDSHAKE_RESET_DATA); + resetPacket.setChannel(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL); + resetPacket.setData(ForgeConstants.FORGE_LEGACY_HANDSHAKE_RESET_DATA); connection.write(resetPacket); connection.setCanSendLegacyFMLResetPacket(false); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeConstants.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeConstants.java index fc69eafe4..ac09d2981 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeConstants.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeConstants.java @@ -1,4 +1,12 @@ package com.velocitypowered.proxy.connection.forge; public class ForgeConstants { + public static final String FORGE_LEGACY_HANDSHAKE_CHANNEL = "FML|HS"; + public static final String FORGE_LEGACY_CHANNEL = "FML"; + public static final String FORGE_MULTIPART_LEGACY_CHANNEL = "FML|MP"; + public static final byte[] FORGE_LEGACY_HANDSHAKE_RESET_DATA = new byte[] { -2, 0 }; + + private ForgeConstants() { + throw new AssertionError(); + } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeUtil.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeUtil.java index f7f283de1..684b14f3d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeUtil.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/ForgeUtil.java @@ -12,10 +12,6 @@ import java.util.List; import java.util.Optional; public class ForgeUtil { - public static final String FORGE_LEGACY_HANDSHAKE_CHANNEL = "FML|HS"; - public static final String FORGE_LEGACY_CHANNEL = "FML"; - public static final String FORGE_MULTIPART_LEGACY_CHANNEL = "FML|MP"; - public static final byte[] FORGE_LEGACY_HANDSHAKE_RESET_DATA = new byte[] { -2, 0 }; private ForgeUtil() { throw new AssertionError(); @@ -23,7 +19,7 @@ public class ForgeUtil { public static Optional> readModList(PluginMessage message) { Preconditions.checkNotNull(message, "message"); - Preconditions.checkArgument(message.getChannel().equals(FORGE_LEGACY_HANDSHAKE_CHANNEL), + Preconditions.checkArgument(message.getChannel().equals(ForgeConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL), "message is not a FML HS plugin message"); ByteBuf byteBuf = Unpooled.wrappedBuffer(message.getData());