Fixed initial porting mistakes

This commit is contained in:
FlorianMichael 2024-02-25 19:26:56 +01:00
parent 4090a6eb12
commit 73fa4d249f
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 10 additions and 7 deletions

View File

@ -117,7 +117,10 @@ public class AddressParser {
if (protocolId == null) { if (protocolId == null) {
protocol = ProtocolVersion.getClosest(arg.replace("_", ".")); protocol = ProtocolVersion.getClosest(arg.replace("_", "."));
} else { } else {
protocol = ProtocolVersion.getProtocol(protocolId); final ProtocolVersion ver = ProtocolVersion.getProtocol(protocolId);
if (ver.isKnown()) {
protocol = ver;
}
} }
} }
} }

View File

@ -56,21 +56,19 @@ object PacketRegistry {
register(State.LOGIN, Direction.SERVERBOUND, ::LoginStart, Range.all(), 0) register(State.LOGIN, Direction.SERVERBOUND, ::LoginStart, Range.all(), 0)
register(State.LOGIN, Direction.SERVERBOUND, ::CryptoResponse, Range.all(), 1) 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, 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, ::LoginDisconnect, Range.all(), 0)
register(State.LOGIN, Direction.CLIENTBOUND, ::CryptoRequest, Range.all(), 1) register(State.LOGIN, Direction.CLIENTBOUND, ::CryptoRequest, Range.all(), 1)
register(State.LOGIN, Direction.CLIENTBOUND, ::LoginSuccess, Range.all(), 2) register(State.LOGIN, Direction.CLIENTBOUND, ::LoginSuccess, Range.all(), 2)
register( register(
State.LOGIN, Direction.CLIENTBOUND, ::SetCompression, mapOf( State.LOGIN, Direction.CLIENTBOUND, ::SetCompression, mapOf(
Range.atLeast(ProtocolVersion.v1_8) to 3, Range.atLeast(ProtocolVersion.v1_8) to 3
sharewareVersion.singleton to 3
) )
) )
register( register(
State.LOGIN, Direction.CLIENTBOUND, ::PluginRequest, mapOf( State.LOGIN, Direction.CLIENTBOUND, ::PluginRequest, mapOf(
Range.atLeast(ProtocolVersion.v1_13) to 4, Range.atLeast(ProtocolVersion.v1_13) to 4
sharewareVersion.singleton to 4
) )
) )

View File

@ -48,7 +48,9 @@ class HandshakeState : ConnectionState {
} }
private fun handleNextState(handler: MinecraftHandler, packet: Handshake) { 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) { when (packet.nextState.ordinal) {
1 -> handler.data.state = StatusState() 1 -> handler.data.state = StatusState()
2 -> handler.data.state = LoginState() 2 -> handler.data.state = LoginState()