Skip to content

Commit

Permalink
Fix for #22 (#32)
Browse files Browse the repository at this point in the history
* Fix for #22

Based on this comment: #22 (comment)

Use ProtocolVersion.MAXIMUM_VERSION to align with Velocity: PaperMC/Velocity@12a05f6

* Move fix under status handshake

Log when the protocol is changed.
  • Loading branch information
Spirit55555 committed Apr 9, 2024
1 parent 096c544 commit 643fed4
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ public boolean handle(LegacyHandshakePacket packet) {
@Override
public boolean handle(HandshakePacket handshake) {
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 643fed4

Please sign in to comment.