Interface MessageCodec<T extends MessageBuffer>

Type Parameters:
T - the type of MessageBuffer used for encoding and decoding

public interface MessageCodec<T extends MessageBuffer>
A codec for encoding and decoding messages.
Since:
2.9.2
  • Method Details

    • readBoolean

      boolean readBoolean(T buffer)
      Reads a boolean value from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the boolean value read
    • readByte

      byte readByte(T buffer)
      Reads a byte value from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the byte value read
    • readShort

      short readShort(T buffer)
      Reads a short value from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the short value read
    • readInt

      int readInt(T buffer)
      Reads an integer value from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the integer value read
    • readFloat

      float readFloat(T buffer)
      Reads a float value from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the float value read
    • readDouble

      double readDouble(T buffer)
      Reads a double value from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the double value read
    • readLong

      long readLong(T buffer)
      Reads a long value from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the long value read
    • readVarInt

      int readVarInt(T buffer)
      Reads a variable-length integer from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the variable-length integer read
    • readUnsignedVarInt

      int readUnsignedVarInt(T buffer)
      Reads an unsigned variable-length integer from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the unsigned variable-length integer read
    • readVarLong

      long readVarLong(T buffer)
      Reads a variable-length long from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the variable-length long read
    • readUnsignedVarLong

      long readUnsignedVarLong(T buffer)
      Reads an unsigned variable-length long from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the unsigned variable-length long read
    • readString

      String readString(T buffer)
      Reads a string from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the string read
    • readString

      String readString(T buffer, int maxLength)
      Reads a string from the buffer.
      Parameters:
      buffer - the buffer to read from
      maxLength - the maximum length of the string to read
      Returns:
      the string read
    • readUuid

      UUID readUuid(T buffer)
      Reads a UUID from the buffer.
      Parameters:
      buffer - the buffer to read from
      Returns:
      the UUID read
    • writeBoolean

      void writeBoolean(T buffer, boolean value)
      Writes a boolean value to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the boolean value to write
    • writeByte

      void writeByte(T buffer, byte value)
      Writes a byte value to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the byte value to write
    • writeShort

      void writeShort(T buffer, short value)
      Writes a short value to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the short value to write
    • writeInt

      void writeInt(T buffer, int value)
      Writes an integer value to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the integer value to write
    • writeFloat

      void writeFloat(T buffer, float value)
      Writes a float value to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the float value to write
    • writeDouble

      void writeDouble(T buffer, double value)
      Writes a double value to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the double value to write
    • writeLong

      void writeLong(T buffer, long value)
      Writes a long value to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the long value to write
    • writeVarInt

      void writeVarInt(T buffer, int value)
      Writes a variable-length integer to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the variable-length integer to write
    • writeUnsignedVarInt

      void writeUnsignedVarInt(T buffer, int value)
      Writes an unsigned variable-length integer to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the unsigned variable-length integer to write
    • writeVarLong

      void writeVarLong(T buffer, long value)
      Writes a variable-length long to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the variable-length long to write
    • writeUnsignedVarLong

      void writeUnsignedVarLong(T buffer, long value)
      Writes an unsigned variable-length long to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the unsigned variable-length long to write
    • writeString

      void writeString(T buffer, String value)
      Writes a string to the buffer.
      Parameters:
      buffer - the buffer to write to
      value - the string to write
    • writeUuid

      void writeUuid(T buffer, UUID uuid)
      Writes a UUID to the buffer.
      Parameters:
      buffer - the buffer to write to
      uuid - the UUID to write
    • createBuffer

      T createBuffer()
      Creates a new buffer instance.
      Returns:
      a new instance of MessageBuffer
    • createBuffer

      T createBuffer(byte[] data)
      Creates a new buffer instance with the given data.
      Parameters:
      data - the byte array to initialize the buffer with
      Returns:
      a new instance of MessageBuffer initialized with the provided data
    • provided

      static <T, C extends MessageCodec<MessageBuffer.Wrapped<T>>> C provided(Class<T> type, MessageCodec.EncoderOptions... options)
      Gets a provided MessageCodec for the given type.
      Type Parameters:
      T - the type of message codec to get
      C - the type of message codec to get
      Parameters:
      type - the type of message codec to get
      options - the encoder options
      Returns:
      the provided message codec
      Throws:
      IllegalArgumentException - if no provider is found