mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-28 23:38:32 +01:00
Address #4281
This commit is contained in:
parent
81178ba2a0
commit
4e0cc92e93
1 changed files with 10 additions and 2 deletions
|
@ -32,18 +32,26 @@ import net.md_5.bungee.protocol.packet.LoginSuccess;
|
||||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||||
|
|
||||||
public class GeyserBungeeCompressionDisabler extends ChannelOutboundHandlerAdapter {
|
public class GeyserBungeeCompressionDisabler extends ChannelOutboundHandlerAdapter {
|
||||||
|
private boolean compressionDisabled = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||||
if (!(msg instanceof SetCompression)) {
|
if (!(msg instanceof SetCompression)) {
|
||||||
if (msg instanceof LoginSuccess) {
|
// Fixes https://github.com/GeyserMC/Geyser/issues/4281
|
||||||
// We're past the point that compression can be enabled
|
// The server may send a LoginDisconnect packet after compression is set.
|
||||||
|
if (!compressionDisabled) {
|
||||||
if (ctx.pipeline().get("compress") != null) {
|
if (ctx.pipeline().get("compress") != null) {
|
||||||
ctx.pipeline().remove("compress");
|
ctx.pipeline().remove("compress");
|
||||||
|
compressionDisabled = true;
|
||||||
}
|
}
|
||||||
if (ctx.pipeline().get("decompress") != null) {
|
if (ctx.pipeline().get("decompress") != null) {
|
||||||
ctx.pipeline().remove("decompress");
|
ctx.pipeline().remove("decompress");
|
||||||
|
compressionDisabled = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg instanceof LoginSuccess) {
|
||||||
|
// We're past the point that compression can be enabled
|
||||||
ctx.pipeline().remove(this);
|
ctx.pipeline().remove(this);
|
||||||
}
|
}
|
||||||
super.write(ctx, msg, promise);
|
super.write(ctx, msg, promise);
|
||||||
|
|
Loading…
Reference in a new issue