diff --git a/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java index a6c9d387a..ee76d772e 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/client/HandshakeSessionHandler.java @@ -24,15 +24,16 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler { } Handshake handshake = (Handshake) packet; - connection.setProtocolVersion(handshake.getProtocolVersion()); switch (handshake.getNextStatus()) { case 1: // Status protocol connection.setState(StateRegistry.STATUS); + connection.setProtocolVersion(handshake.getProtocolVersion()); connection.setSessionHandler(new StatusSessionHandler(connection)); break; case 2: connection.setState(StateRegistry.LOGIN); + connection.setProtocolVersion(handshake.getProtocolVersion()); if (!ProtocolConstants.isSupported(handshake.getProtocolVersion())) { connection.closeWith(Disconnect.create(TextComponent.of("Unsupported client"))); return; diff --git a/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java b/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java index bced97e73..e1a6a5f82 100644 --- a/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java +++ b/src/main/java/com/velocitypowered/proxy/connection/client/StatusSessionHandler.java @@ -11,6 +11,8 @@ import com.velocitypowered.proxy.protocol.packets.StatusResponse; import com.velocitypowered.proxy.connection.MinecraftConnection; import com.velocitypowered.proxy.data.ServerPing; import com.velocitypowered.proxy.connection.MinecraftSessionHandler; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; public class StatusSessionHandler implements MinecraftSessionHandler { private final MinecraftConnection connection; @@ -43,4 +45,9 @@ public class StatusSessionHandler implements MinecraftSessionHandler { response.setStatus(VelocityServer.GSON.toJson(ping)); connection.write(response); } + + @Override + public void handleUnknown(ByteBuf buf) { + throw new IllegalStateException("Unknown data " + ByteBufUtil.hexDump(buf)); + } } diff --git a/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java b/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java index af97c37a5..d40f57a88 100644 --- a/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java +++ b/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java @@ -45,17 +45,13 @@ public enum StateRegistry { map(0x04, MINECRAFT_1_12_1)); CLIENTBOUND.register(Chat.class, Chat::new, - map(0x0F, MINECRAFT_1_11), - map(0x0F, MINECRAFT_1_12)); + map(0x0F, MINECRAFT_1_11)); CLIENTBOUND.register(Disconnect.class, Disconnect::new, - map(0x1A, MINECRAFT_1_11), - map(0x1A, MINECRAFT_1_12)); + map(0x1A, MINECRAFT_1_11)); CLIENTBOUND.register(KeepAlive.class, KeepAlive::new, - map(0x1F, MINECRAFT_1_11), - map(0x1F, MINECRAFT_1_12)); + map(0x1F, MINECRAFT_1_11)); CLIENTBOUND.register(JoinGame.class, JoinGame::new, - map(0x23, MINECRAFT_1_11), - map(0x23, MINECRAFT_1_12)); + map(0x23, MINECRAFT_1_11)); CLIENTBOUND.register(Respawn.class, Respawn::new, map(0x33, MINECRAFT_1_11), map(0x34, MINECRAFT_1_12), @@ -87,7 +83,7 @@ public enum StateRegistry { private static final IntObjectMap LINKED_PROTOCOL_VERSIONS = new IntObjectHashMap<>(); static { - LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_11, new int[] { MINECRAFT_1_11_1 }); + LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_11, new int[] { MINECRAFT_1_11_1, MINECRAFT_1_12 }); LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12, new int[] { MINECRAFT_1_12_1 }); LINKED_PROTOCOL_VERSIONS.put(MINECRAFT_1_12_1, new int[] { MINECRAFT_1_12_2 }); }