Class BufferReader


  • public class BufferReader
    extends java.lang.Object
    Reverses the obfuscated buffer encoding written by BufferUtils.

    The write side encodes each field by:

    1. Advancing a logical offset by offsetMultiplier once per byte written.
    2. Computing the real array index as offset * indexMultiplier - 1.
    3. Writing one byte derived from the full field value via the BufferOperation:
      • RAW → (byte) value
      • ADD(x) → (byte)(x + value)
      • SUBTRACT(x) → (byte)(x - value)
      • RIGHT_SHIFT(n) → (byte)(value >> n)

    Reading back is the mirror image:

    • Replay the same offset arithmetic to find each byte in the payload.
    • Invert the obfuscation to recover the byte's bit contribution.
    • OR all bit contributions for the same field together to get the original value.

    The indexMultiplier and offsetMultiplier are the same obfuscated constants used by BufferUtils and are loaded from PacketFactory.getPacketMetadata.

    • Constructor Summary

      Constructors 
      Constructor Description
      BufferReader()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String debugDecode​(java.lang.String packetName, byte[] payload, java.util.List<PacketWrite> writes)
      Decodes the payload and returns a human-readable string, e.g.:
      static java.util.Map<java.lang.String,​java.lang.Object> decode​(byte[] payload, java.util.List<PacketWrite> writes)
      Decodes an encoded packet payload into a map of param → value entries, in the order the writes were originally performed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BufferReader

        public BufferReader()
    • Method Detail

      • decode

        public static java.util.Map<java.lang.String,​java.lang.Object> decode​(byte[] payload,
                                                                                    java.util.List<PacketWrite> writes)
        Decodes an encoded packet payload into a map of param → value entries, in the order the writes were originally performed.
        Parameters:
        payload - the raw bytes captured from the packet buffer (after Isaac cipher decoding)
        writes - the ordered list of PacketWrite descriptors for this packet opcode
        Returns:
        a LinkedHashMap preserving write order, values as Integer or String
      • debugDecode

        public static java.lang.String debugDecode​(java.lang.String packetName,
                                                   byte[] payload,
                                                   java.util.List<PacketWrite> writes)
        Decodes the payload and returns a human-readable string, e.g.:
           OPOBJ1 { objectId=41096, worldPointX=3221, worldPointY=3219, ctrlDown=0, subop=0 }
         
        Parameters:
        packetName - the display name of the packet opcode (e.g. "OPOBJ1")
        payload - the encoded payload bytes
        writes - the ordered PacketWrite descriptors for this opcode
        Returns:
        a debug string