From 57e3a3ccdb8fa627f1ec705e627858974a60497b Mon Sep 17 00:00:00 2001 From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com> Date: Tue, 7 Oct 2025 22:02:12 -0700 Subject: [PATCH] Log error on protocol encode & decode fail --- .../protocol/core/LeavesProtocolManager.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java index f6300c8e..88b6ead4 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java @@ -205,7 +205,12 @@ public class LeavesProtocolManager { if (codec == null) { return null; } - return codec.decode(ProtocolUtils.decorate(buf)); + try { + return codec.decode(ProtocolUtils.decorate(buf)); + } catch (Exception e) { + LOGGER.severe("Failed to decode " + location, e); + throw e; + } } public static void encode(FriendlyByteBuf buf, LeavesCustomPayload payload) { @@ -214,8 +219,13 @@ public class LeavesProtocolManager { if (location == null || codec == null) { throw new IllegalArgumentException("Payload " + payload.getClass() + " is not configured correctly " + location + " " + codec); } - buf.writeResourceLocation(location); - codec.encode(ProtocolUtils.decorate(buf), payload); + try { + buf.writeResourceLocation(location); + codec.encode(ProtocolUtils.decorate(buf), payload); + } catch (Exception e) { + LOGGER.severe("Failed to encode payload " + location, e); + throw e; + } } public static void handlePayload(IdentifierSelector selector, LeavesCustomPayload payload) {