Skip to content

Commit

Permalink
Move fix under status handshake
Browse files Browse the repository at this point in the history
Log when the protocol is changed.
  • Loading branch information
Spirit55555 authored and UserNugget committed Apr 9, 2024
1 parent a22e943 commit 145440c
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,19 @@ public boolean handle(LegacyHandshakePacket packet) {

@Override
public boolean handle(HandshakePacket handshake) {
if (handshake.getProtocolVersion() == null || handshake.getProtocolVersion() == ProtocolVersion.UNKNOWN) {
handshake.setProtocolVersion(ProtocolVersion.MAXIMUM_VERSION);
}

if (handshake.getNextStatus() == StateRegistry.STATUS_ID) {
if (handshake.getProtocolVersion() == null || handshake.getProtocolVersion() == ProtocolVersion.UNKNOWN) {
handshake.setProtocolVersion(ProtocolVersion.MAXIMUM_VERSION);

if (Settings.IMP.MAIN.LOG_PINGS) {
this.plugin.getLogger().info(
"Unknown protocol version detected from {}, replaced with version {}",
this.connection.getRemoteAddress(),
ProtocolVersion.MAXIMUM_VERSION
);
}
}

this.protocolVersion = handshake.getProtocolVersion();
this.serverAddress = handshake.getServerAddress() + ":" + handshake.getPort();
this.channel.pipeline().remove(Connections.FRAME_ENCODER);
Expand Down

0 comments on commit 145440c

Please sign in to comment.