From 73fa4d249fc63beff70a315a663bb3648a977bbc Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sun, 25 Feb 2024 19:26:56 +0100 Subject: [PATCH] Fixed initial porting mistakes --- src/main/java/com/viaversion/aas/util/AddressParser.java | 5 ++++- .../com/viaversion/aas/codec/packet/PacketRegistry.kt | 8 +++----- .../com/viaversion/aas/handler/state/HandshakeState.kt | 4 +++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/viaversion/aas/util/AddressParser.java b/src/main/java/com/viaversion/aas/util/AddressParser.java index 867a4c5..51b62c2 100644 --- a/src/main/java/com/viaversion/aas/util/AddressParser.java +++ b/src/main/java/com/viaversion/aas/util/AddressParser.java @@ -117,7 +117,10 @@ public class AddressParser { if (protocolId == null) { protocol = ProtocolVersion.getClosest(arg.replace("_", ".")); } else { - protocol = ProtocolVersion.getProtocol(protocolId); + final ProtocolVersion ver = ProtocolVersion.getProtocol(protocolId); + if (ver.isKnown()) { + protocol = ver; + } } } } diff --git a/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt b/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt index 9e50157..c276765 100644 --- a/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt +++ b/src/main/kotlin/com/viaversion/aas/codec/packet/PacketRegistry.kt @@ -56,21 +56,19 @@ object PacketRegistry { register(State.LOGIN, Direction.SERVERBOUND, ::LoginStart, Range.all(), 0) register(State.LOGIN, Direction.SERVERBOUND, ::CryptoResponse, Range.all(), 1) register(State.LOGIN, Direction.SERVERBOUND, ::PluginResponse, Range.atLeast(ProtocolVersion.v1_13), 2) - register(State.LOGIN, Direction.SERVERBOUND, ::PluginResponse, sharewareVersion.singleton, 2) +// register(State.LOGIN, Direction.SERVERBOUND, ::PluginResponse, sharewareVersion.singleton, 2) register(State.LOGIN, Direction.CLIENTBOUND, ::LoginDisconnect, Range.all(), 0) register(State.LOGIN, Direction.CLIENTBOUND, ::CryptoRequest, Range.all(), 1) register(State.LOGIN, Direction.CLIENTBOUND, ::LoginSuccess, Range.all(), 2) register( State.LOGIN, Direction.CLIENTBOUND, ::SetCompression, mapOf( - Range.atLeast(ProtocolVersion.v1_8) to 3, - sharewareVersion.singleton to 3 + Range.atLeast(ProtocolVersion.v1_8) to 3 ) ) register( State.LOGIN, Direction.CLIENTBOUND, ::PluginRequest, mapOf( - Range.atLeast(ProtocolVersion.v1_13) to 4, - sharewareVersion.singleton to 4 + Range.atLeast(ProtocolVersion.v1_13) to 4 ) ) diff --git a/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt b/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt index 052b8ed..14f8d70 100644 --- a/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt +++ b/src/main/kotlin/com/viaversion/aas/handler/state/HandshakeState.kt @@ -48,7 +48,9 @@ class HandshakeState : ConnectionState { } private fun handleNextState(handler: MinecraftHandler, packet: Handshake) { - handler.data.frontVer = ProtocolVersion.getProtocol(packet.protocolId) + ProtocolVersion.getProtocol(packet.protocolId).apply { + if (this.isKnown) handler.data.frontVer = this + } when (packet.nextState.ordinal) { 1 -> handler.data.state = StatusState() 2 -> handler.data.state = LoginState()