Skip to content

Commit

Permalink
Fixed initial porting mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Feb 25, 2024
1 parent 4090a6e commit 73fa4d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/main/java/com/viaversion/aas/util/AddressParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ public void parseProtocol(String arg) {
if (protocolId == null) {
protocol = ProtocolVersion.getClosest(arg.replace("_", "."));
} else {
protocol = ProtocolVersion.getProtocol(protocolId);
final ProtocolVersion ver = ProtocolVersion.getProtocol(protocolId);
if (ver.isKnown()) {
protocol = ver;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 73fa4d2

Please sign in to comment.