From 25652eab1524b812cc80ea0e65531c00f06e766b Mon Sep 17 00:00:00 2001 From: KennyTV Date: Sat, 6 Jun 2020 16:16:38 +0200 Subject: [PATCH] Print protocol and packet type when erroring --- .../ViaVersion/api/protocol/Protocol.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java index 56e8c2fcc..119359495 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/Protocol.java @@ -406,15 +406,36 @@ public abstract class Protocol packetTypeClass = direction == Direction.OUTGOING ? oldClientboundPacketEnum : newServerboundPacketEnum; + if (packetTypeClass != null) { + PacketType[] enumConstants = packetTypeClass.getEnumConstants(); + PacketType packetType = oldId < enumConstants.length && oldId >= 0 ? enumConstants[oldId] : null; + Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + " IN REMAP OF " + packetType + " (" + oldId + ")"); + } else { + Via.getPlatform().getLogger().warning("ERROR IN " + getClass().getSimpleName() + + " IN REMAP OF 0x" + Integer.toHexString(oldId) + "->0x" + Integer.toHexString(newId)); + } + throw e; + } + + if (packetWrapper.isCancelled()) { + throw Via.getManager().isDebug() ? new CancelException() : CancelException.CACHED; } }