Fix 1.17 BungeeCord support

This commit is contained in:
Myles 2021-06-14 19:46:25 +01:00
parent 34a0499152
commit 86278e837a
1 changed files with 10 additions and 4 deletions

View File

@ -70,11 +70,17 @@ public class BungeeEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
if (ctx.pipeline().names().indexOf("compress") > ctx.pipeline().names().indexOf("via-encoder")) {
// Need to decompress this packet due to bad order
ByteBuf decompressed = BungeePipelineUtil.decompress(ctx, buf);
try {
buf.clear().writeBytes(decompressed);
} finally {
decompressed.release();
// Ensure the buffer wasn't reused
if (buf != decompressed) {
try {
buf.clear().writeBytes(decompressed);
} finally {
decompressed.release();
}
}
// Reorder the pipeline
ChannelHandler dec = ctx.pipeline().get("via-decoder");
ChannelHandler enc = ctx.pipeline().get("via-encoder");
ctx.pipeline().remove(dec);