diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java index b53b1e50ff..9028dc1303 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java @@ -47,7 +47,7 @@ public class ProtocolConstants public static final int MINECRAFT_1_20_3 = 765; public static final int MINECRAFT_1_20_5 = 766; public static final int MINECRAFT_1_21 = 767; - public static final int MINECRAFT_1_21_2 = 1073742032; + public static final int MINECRAFT_1_21_2 = 1073742034; public static final List SUPPORTED_VERSIONS; public static final List SUPPORTED_VERSION_IDS; diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java index 60ff5700c9..daa6d18306 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/packet/LoginSuccess.java @@ -37,7 +37,7 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco { properties = readProperties( buf ); } - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 && protocolVersion < ProtocolConstants.MINECRAFT_1_21_2 ) { // Whether the client should disconnect on its own if it receives invalid data from the server buf.readBoolean(); @@ -59,7 +59,7 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc { writeProperties( properties, buf ); } - if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 ) + if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 && protocolVersion < ProtocolConstants.MINECRAFT_1_21_2 ) { // Whether the client should disconnect on its own if it receives invalid data from the server // Vanilla sends true so we also send true diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 091ae9a226..224f231b63 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -196,6 +196,7 @@ public void handle(PluginMessage pluginMessage) throws Exception @Override public void handle(LegacyHandshake legacyHandshake) throws Exception { + Preconditions.checkState( !this.legacy, "Not expecting LegacyHandshake" ); this.legacy = true; ch.close( bungee.getTranslation( "outdated_client", bungee.getGameVersion() ) ); } @@ -203,6 +204,7 @@ public void handle(LegacyHandshake legacyHandshake) throws Exception @Override public void handle(LegacyPing ping) throws Exception { + Preconditions.checkState( !this.legacy, "Not expecting LegacyPing" ); this.legacy = true; final boolean v1_5 = ping.isV1_5(); @@ -342,7 +344,7 @@ public void handle(PingPacket ping) throws Exception @Override public void handle(Handshake handshake) throws Exception { - Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" ); + Preconditions.checkState( thisState == State.HANDSHAKE && !this.legacy, "Not expecting HANDSHAKE" ); this.handshake = handshake; ch.setVersion( handshake.getProtocolVersion() ); ch.getHandle().pipeline().remove( PipelineUtils.LEGACY_KICKER ); @@ -420,7 +422,7 @@ public void handle(Handshake handshake) throws Exception @Override public void handle(LoginRequest loginRequest) throws Exception { - Preconditions.checkState( thisState == State.USERNAME, "Not expecting USERNAME" ); + Preconditions.checkState( thisState == State.USERNAME && this.loginRequest == null, "Not expecting USERNAME" ); if ( !AllowedCharacters.isValidName( loginRequest.getData(), onlineMode ) ) {