From 4e0cc92e93cf9e7f9bd9f529968aac7fe04a9153 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sat, 11 Nov 2023 13:26:28 -0500 Subject: [PATCH] Address #4281 --- .../bungeecord/GeyserBungeeCompressionDisabler.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeCompressionDisabler.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeCompressionDisabler.java index 084e1d2dc..485079a05 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeCompressionDisabler.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeCompressionDisabler.java @@ -32,18 +32,26 @@ import net.md_5.bungee.protocol.packet.LoginSuccess; import net.md_5.bungee.protocol.packet.SetCompression; public class GeyserBungeeCompressionDisabler extends ChannelOutboundHandlerAdapter { + private boolean compressionDisabled = false; @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { if (!(msg instanceof SetCompression)) { - if (msg instanceof LoginSuccess) { - // We're past the point that compression can be enabled + // Fixes https://github.com/GeyserMC/Geyser/issues/4281 + // The server may send a LoginDisconnect packet after compression is set. + if (!compressionDisabled) { if (ctx.pipeline().get("compress") != null) { ctx.pipeline().remove("compress"); + compressionDisabled = true; } if (ctx.pipeline().get("decompress") != null) { ctx.pipeline().remove("decompress"); + compressionDisabled = true; } + } + + if (msg instanceof LoginSuccess) { + // We're past the point that compression can be enabled ctx.pipeline().remove(this); } super.write(ctx, msg, promise);