diff --git a/src/main/kotlin/com/github/creeper123123321/viaaas/codec/MinecraftCodec.kt b/src/main/kotlin/com/github/creeper123123321/viaaas/codec/MinecraftCodec.kt index 321417f..df907cd 100644 --- a/src/main/kotlin/com/github/creeper123123321/viaaas/codec/MinecraftCodec.kt +++ b/src/main/kotlin/com/github/creeper123123321/viaaas/codec/MinecraftCodec.kt @@ -7,10 +7,11 @@ import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBufAllocator import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.MessageToMessageCodec +import us.myles.ViaVersion.exception.CancelEncoderException class MinecraftCodec : MessageToMessageCodec() { override fun encode(ctx: ChannelHandlerContext, msg: Packet, out: MutableList) { - if (!ctx.channel().isActive) return + if (!ctx.channel().isActive) throw CancelEncoderException.CACHED val buf = ByteBufAllocator.DEFAULT.buffer() try { val handler = ctx.pipeline().get(MinecraftHandler::class.java) diff --git a/src/main/kotlin/com/github/creeper123123321/viaaas/handler/ViaCodec.kt b/src/main/kotlin/com/github/creeper123123321/viaaas/handler/ViaCodec.kt index a12a25a..519b9ad 100644 --- a/src/main/kotlin/com/github/creeper123123321/viaaas/handler/ViaCodec.kt +++ b/src/main/kotlin/com/github/creeper123123321/viaaas/handler/ViaCodec.kt @@ -25,6 +25,7 @@ class ViaCodec(val info: UserConnection) : MessageToMessageCodec) { + if (!ctx.channel().isActive) throw CancelEncoderException.CACHED if (!info.checkOutgoingPacket()) throw CancelEncoderException.generate(null) if (!info.shouldTransformPacket()) { out.add(bytebuf.retain())