diff --git a/BungeeCord-Patches/0041-Dump-the-raw-hex-of-a-packet-on-a-decoding-error.patch b/BungeeCord-Patches/0041-Dump-the-raw-hex-of-a-packet-on-a-decoding-error.patch new file mode 100644 index 0000000..837d0fd --- /dev/null +++ b/BungeeCord-Patches/0041-Dump-the-raw-hex-of-a-packet-on-a-decoding-error.patch @@ -0,0 +1,57 @@ +From a1fa37e05b144a458cf44632dd337b405df8e04a Mon Sep 17 00:00:00 2001 +From: Techcable +Date: Thu, 4 Aug 2016 19:30:49 -0700 +Subject: [PATCH] Dump the raw hex of a packet on a decoding error + + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +index 447eaae..17d8444 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +@@ -1,7 +1,9 @@ + package net.md_5.bungee.protocol; + + import io.netty.buffer.ByteBuf; ++import io.netty.buffer.ByteBufUtil; + import io.netty.channel.ChannelHandlerContext; ++import io.netty.handler.codec.DecoderException; + import io.netty.handler.codec.MessageToMessageDecoder; + import java.util.List; + import lombok.AllArgsConstructor; +@@ -31,13 +33,16 @@ public class MinecraftDecoder extends MessageToMessageDecoder + Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT; + ByteBuf slice = in.copy(); // Can't slice this one due to EntityMap :( + ++ Object packetTypeInfo = null; + try + { + int packetId = DefinedPacket.readVarInt( in ); ++ packetTypeInfo = packetId; + + DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge ); + if ( packet != null ) + { ++ packetTypeInfo = packet.getClass(); + packet.read( in, prot.getDirection(), protocolVersion ); + + if ( in.isReadable() ) +@@ -51,6 +56,16 @@ public class MinecraftDecoder extends MessageToMessageDecoder + + out.add( new PacketWrapper( packet, slice ) ); + slice = null; ++ } catch (BadPacketException | IndexOutOfBoundsException e) { ++ final String packetTypeStr; ++ if (packetTypeInfo instanceof Integer) { ++ packetTypeStr = "id " + Integer.toHexString((Integer) packetTypeInfo); ++ } else if (packetTypeInfo instanceof Class) { ++ packetTypeStr = "class " + ((Class) packetTypeInfo).getSimpleName(); ++ } else { ++ packetTypeStr = "unknown"; ++ } ++ throw new DecoderException("Error decoding packet " + packetTypeStr + " with contents " + ByteBufUtil.prettyHexDump(slice)); + } finally + { + if ( slice != null ) +-- +2.9.0 +