Skip to content

Commit

Permalink
Merge branch 'refs/heads/improve-protocol-state' into translatable-me…
Browse files Browse the repository at this point in the history
…ssages
  • Loading branch information
AlexProgrammerDE committed Jun 16, 2024
2 parents 9be5568 + 4a9adfb commit 75883a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void packetReceived(Session session, Packet packet) {
public void connected(ConnectedEvent event) {
Session session = event.getSession();
MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
ClientIntentionPacket intention = new ClientIntentionPacket(protocol.getCodec().getProtocolVersion(), event.getSession().getHost(), event.getSession().getPort(), switch (this.targetState) {
ClientIntentionPacket intention = new ClientIntentionPacket(protocol.getCodec().getProtocolVersion(), session.getHost(), session.getPort(), switch (this.targetState) {
case LOGIN -> transferring ? HandshakeIntent.TRANSFER : HandshakeIntent.LOGIN;
case STATUS -> HandshakeIntent.STATUS;
default -> throw new IllegalStateException("Unexpected value: " + this.targetState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ private void beginLogin(Session session, MinecraftProtocol protocol, ClientInten
isTransfer = transferred;
session.switchOutboundProtocol(() -> protocol.setOutboundState(ProtocolState.LOGIN));
if (packet.getProtocolVersion() > protocol.getCodec().getProtocolVersion()) {
session.disconnect(Component.translatable("multiplayer.disconnect.incompatible", protocol.getCodec().getMinecraftVersion()));
session.disconnect(Component.translatable("multiplayer.disconnect.incompatible", Component.text(protocol.getCodec().getMinecraftVersion())));
} else if (packet.getProtocolVersion() < protocol.getCodec().getProtocolVersion()) {
session.disconnect(Component.translatable("multiplayer.disconnect.outdated_client", protocol.getCodec().getMinecraftVersion()));
session.disconnect(Component.translatable("multiplayer.disconnect.outdated_client", Component.text(protocol.getCodec().getMinecraftVersion())));
} else {
session.switchInboundProtocol(() -> protocol.setInboundState(ProtocolState.LOGIN));
}
Expand Down

0 comments on commit 75883a8

Please sign in to comment.