From 11402041574c17cda37fba7ce9d50e8779d05279 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Thu, 9 Nov 2023 02:07:59 +0800 Subject: [PATCH] Don't process inactive channel + skip remaining bytes --- build.gradle.kts | 2 +- .../axiom/packet/AxiomBigPayloadHandler.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index caa783c..ebacafe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -25,7 +25,7 @@ repositories { } dependencies { - paperweight.paperDevBundle("1.20.2-R0.1-20231010.011415-29") + paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT") implementation("xyz.jpenilla:reflection-remapper:0.1.0-SNAPSHOT") // Zstd Compression Library diff --git a/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java b/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java index 57c1748..60fa216 100644 --- a/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java +++ b/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java @@ -26,6 +26,12 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder { @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { + // Don't process if channel isn't active + if (!ctx.channel().isActive()) { + in.skipBytes(in.readableBytes()); + return; + } + int i = in.readableBytes(); if (i != 0) { int readerIndex = in.readerIndex(); @@ -55,6 +61,11 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder { } ctx.fireChannelRead(in.retain()); + + // Skip remaining bytes + if (in.readableBytes() > 0) { + in.skipBytes(in.readableBytes()); + } } @Override