From 93c618a150fa06578d6e4cce96522d12d16ca659 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Tue, 7 Nov 2023 19:29:12 +0800 Subject: [PATCH] Don't log exceptions in Big Payload Handler --- .../axiom/packet/AxiomBigPayloadHandler.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java b/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java index eb64174..57c1748 100644 --- a/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java +++ b/src/main/java/com/moulberry/axiom/packet/AxiomBigPayloadHandler.java @@ -26,10 +26,11 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder { @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { - try { + int i = in.readableBytes(); + if (i != 0) { int readerIndex = in.readerIndex(); - int i = in.readableBytes(); - if (i != 0) { + boolean success = false; + try { FriendlyByteBuf buf = new FriendlyByteBuf(in); int packetId = buf.readVarInt(); @@ -39,15 +40,18 @@ public class AxiomBigPayloadHandler extends ByteToMessageDecoder { ServerPlayer player = connection.getPlayer(); if (player != null && player.getBukkitEntity().hasPermission("axiom.*")) { if (listener.onReceive(player, buf)) { + success = true; return; } } } } + } catch (Throwable ignored) { + } finally { + if (!success) { + in.readerIndex(readerIndex); + } } - in.readerIndex(readerIndex); - } catch (Exception e) { - e.printStackTrace(); } ctx.fireChannelRead(in.retain());