From cc906000bcf6c978de1c230b8580758996ff9854 Mon Sep 17 00:00:00 2001 From: Adrian <68704415+4drian3d@users.noreply.github.com> Date: Thu, 11 Jan 2024 01:57:03 -0500 Subject: [PATCH] Fixed Legacy Ping handling (#1180) --- .../proxy/connection/MinecraftConnection.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index bb0c4db72..e9f503f7d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -362,8 +362,17 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { ensureInEventLoop(); this.state = state; - this.channel.pipeline().get(MinecraftEncoder.class).setState(state); - this.channel.pipeline().get(MinecraftDecoder.class).setState(state); + // If the connection is LEGACY (<1.6), the decoder and encoder are not set. + final MinecraftEncoder minecraftEncoder = this.channel.pipeline() + .get(MinecraftEncoder.class); + if (minecraftEncoder != null) { + minecraftEncoder.setState(state); + } + final MinecraftDecoder minecraftDecoder = this.channel.pipeline() + .get(MinecraftDecoder.class); + if (minecraftDecoder != null) { + minecraftDecoder.setState(state); + } if (state == StateRegistry.CONFIG) { // Activate the play packet queue