gt:                     value |= readByte(false) << 16;
context: package server.core.net.packet;
  
  import java.nio.ByteBuffer;
  
  /**
   * An abstract parent class for two buffer type objects, one for reading data
   * and one for writing data. Provides static factory methods for initializing
   * these child buffers. This buffer has been edited to write raw packet headers.
   * 
   * @author blakeman8192
   * @author lare96
   */
  public abstract class PacketBuffer {
  
      /**
       * An enum whose values represent the possible order in which bytes are
       * written in a multiple-byte value. Also known as "endianness".
       * 
       * @author blakeman8192
       */
      public static enum ByteOrder {
          LITTLE, BIG, MIDDLE, INVERSE_MIDDLE
      }
  
      /**
       * An enum whose values represent the possible custom RuneScape value types.
       * Type A is to add 128 to the value, type C is to invert the value, and
       * type S is to subtract the value from 128. Of course, STANDARD is just the
       * normal data value.
       * 
       * @author blakeman8192
       */
      public static enum ValueType {
          STANDARD, A, C, S
      }
  
      /**
       * An enum whose values represent the current type of access to a
       * StreamBuffer. BYTE_ACCESS is for reading/writing bytes, BIT_ACCESS is for
       * reading/writing bits.
       * 
       * @author blakeman8192
       */
      public static enum AccessType {
          BYTE_ACCESS, BIT_ACCESS
      }
  
      /**
       * Bit masks.
       */
      public static final int[] BIT_MASK = { 0, 0x1, 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1 };
  
      /** The current AccessType of the buffer. */
      private AccessType accessType = AccessType.BYTE_ACCESS;
  
      /** The current bit position. */
      private int bitPosition = 0;
  
      /**
       * Creates a new InBuffer.
       * 
       * @param data
       *        the data
       * @return a new InBuffer
       */
      public static final ReadBuffer newReadBuffer(ByteBuffer data) {
          return new ReadBuffer(data);
      }
  
      /**
       * Creates a new OutBuffer.
       * 
       * @param size
       *        the size
       * @return a new OutBuffer
       */
      public static final WriteBuffer newWriteBuffer(int size) {
          return new WriteBuffer(size);
      }
  
      /**
       * Handles the internal switching of the access type.
       * 
       * @param type
       *        the new access type
       */
      abstract void switchAccessType(AccessType type);
  
      /**
       * Sets the AccessType of this StreamBuffer.
       * 
       * @param accessType
       *        the new AccessType
       */
      public void setAccessType(AccessType accessType) {
          this.accessType = accessType;
          switchAccessType(accessType);
      }
  
      /**
       * Gets the AccessType of this StreamBuffer.
       * 
       * @return the current AccessType
       */
      public AccessType getAccessType() {
          return accessType;
      }
  
      /**
       * Sets the bit position.
       * 
       * @param bitPosition
       *        the new bit position
       */
      public void setBitPosition(int bitPosition) {
          this.bitPosition = bitPosition;
      }
  
      /**
       * Gets the current bit position.
       * 
       * @return the bit position
       */
      public int getBitPosition() {
          return bitPosition;
      }
  
      /**
       * A PacketBuffer used to read incoming data.
       * 
       * @author blakeman8192
       */
      public static final class ReadBuffer extends PacketBuffer {
  
          /** The internal buffer. */
          private ByteBuffer buffer;
  
          /**
           * Creates a new InBuffer.
           * 
           * @param buffer
           *        the buffer
           */
          private ReadBuffer(ByteBuffer buffer) {
              this.buffer = buffer;
          }
  
          @Override
          void switchAccessType(AccessType type) {
              if (type == AccessType.BIT_ACCESS) {
                  throw new UnsupportedOperationException("Reading bits is not implemented!");
              }
          }
  
          /**
           * Reads a value as a byte.
           * 
           * @param signed
           *        the signedness
           * @param type
           *        the value type
           * @return the value
           */
          public int readByte(boolean signed, ValueType type) {
              int value = buffer.get();
              switch (type) {
                  case A:
                      value = value - 128;
                      break;
                  case C:
                      value = -value;
                      break;
                  case S:
                      value = 128 - value;
                      break;
                  case STANDARD:
                      break;
              }
              return signed ? value : value & 0xff;
          }
  
          /**
           * Reads a standard signed byte.
           * 
           * @return the value
           */
          public int readByte() {
              return readByte(true, ValueType.STANDARD);
          }
  
          /**
           * Reads a standard byte.
           * 
           * @param signed
           *        the signedness
           * @return the value
           */
          public int readByte(boolean signed) {
              return readByte(signed, ValueType.STANDARD);
          }
  
          /**
           * Reads a signed byte.
           * 
           * @param type
           *        the value type
           * @return the value
           */
          public int readByte(ValueType type) {
              return readByte(true, type);
          }
  
          /**
           * Reads a short value.
           * 
           * @param signed
           *        the signedness
           * @param type
           *        the value type
           * @param order
           *        the byte order
           * @return the value
           */
          public int readShort(boolean signed, ValueType type, ByteOrder order) {
              int value = 0;
              switch (order) {
                  case BIG:
                      value |= readByte(false) << 8;
                      value |= readByte(false, type);
                      break;
                  case MIDDLE:
                      throw new UnsupportedOperationException("Middle-endian short is impossible!");
                  case INVERSE_MIDDLE:
                      throw new UnsupportedOperationException("Inverse-middle-endian short is impossible!");
                  case LITTLE:
                      value |= readByte(false, type);
                      value |= readByte(false) << 8;
                      break;
              }
              return signed ? value : value & 0xffff;
          }
  
          /**
           * Reads a standard signed big-endian short.
           * 
           * @return the value
           */
          public int readShort() {
              return readShort(true, ValueType.STANDARD, ByteOrder.BIG);
          }
  
          /**
           * Reads a standard big-endian short.
           * 
           * @param signed
           *        the signedness
           * @return the value
           */
          public int readShort(boolean signed) {
              return readShort(signed, ValueType.STANDARD, ByteOrder.BIG);
          }
  
          /**
           * Reads a signed big-endian short.
           * 
           * @param type
           *        the value type
           * @return the value
           */
          public int readShort(ValueType type) {
              return readShort(true, type, ByteOrder.BIG);
          }
  
          /**
           * Reads a big-endian short.
           * 
           * @param signed
           *        the signedness
           * @param type
           *        the value type
           * @return the value
           */
          public int readShort(boolean signed, ValueType type) {
              return readShort(signed, type, ByteOrder.BIG);
          }
  
          /**
           * Reads a signed standard short.
           * 
           * @param order
           *        the byte order
           * @return the value
           */
          public int readShort(ByteOrder order) {
              return readShort(true, ValueType.STANDARD, order);
          }
  
          /**
           * Reads a standard short.
           * 
           * @param signed
           *        the signedness
           * @param order
           *        the byte order
           * @return the value
           */
          public int readShort(boolean signed, ByteOrder order) {
              return readShort(signed, ValueType.STANDARD, order);
          }
  
          /**
           * Reads a signed short.
           * 
           * @param type
           *        the value type
           * @param order
           *        the byte order
           * @return the value
           */
          public int readShort(ValueType type, ByteOrder order) {
              return readShort(true, type, order);
          }
  
          /**
           * Reads an integer.
           * 
           * @param signed
           *        the signedness
           * @param type
           *        the value type
           * @param order
           *        the byte order
           * @return the value
           */
          public long readInt(boolean signed, ValueType type, ByteOrder order) {
              long value = 0;
              switch (order) {
                  case BIG:
                      value |= readByte(false) << 24;
                      value |= readByte(false) << 16;
                      value |= readByte(false) << 8;
                      value |= readByte(false, type);
                      break;
                  case MIDDLE:
                      value |= readByte(false) << 8;
                      value |= readByte(false, type);
                      value |= readByte(false) << 24;
  