Class BinaryReader

java.lang.Object
java.io.InputStream
net.minestom.server.utils.binary.BinaryReader
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable

public class BinaryReader
extends java.io.InputStream
Class used to read from a byte array.

WARNING: not thread-safe.

  • Constructor Details

    • BinaryReader

      public BinaryReader​(@NotNull io.netty.buffer.ByteBuf buffer)
    • BinaryReader

      public BinaryReader​(byte[] bytes)
  • Method Details

    • readVarInt

      public int readVarInt()
    • readBoolean

      public boolean readBoolean()
    • readByte

      public byte readByte()
    • readShort

      public short readShort()
    • readChar

      public char readChar()
    • readUnsignedShort

      public int readUnsignedShort()
    • readInteger

      public int readInteger()
    • readLong

      public long readLong()
    • readFloat

      public float readFloat()
    • readDouble

      public double readDouble()
    • readSizedString

      public java.lang.String readSizedString​(int maxLength)
      Reads a string size by a var-int.

      If the string length is higher than maxLength, the code throws an exception and the string bytes are not read.

      Parameters:
      maxLength - the max length of the string
      Returns:
      the string
      Throws:
      java.lang.IllegalStateException - if the string length is higher than maxLength
    • readBytes

      public byte[] readBytes​(int length)
    • readSizedStringArray

      public java.lang.String[] readSizedStringArray​(int maxLength)
    • readVarIntArray

      public int[] readVarIntArray()
    • getRemainingBytes

      public byte[] getRemainingBytes()
    • readBlockPosition

      public BlockPosition readBlockPosition()
    • readUuid

      public java.util.UUID readUuid()
    • readSlot

      public ItemStack readSlot()
      Tries to read an ItemStack.
      Returns:
      the read item
      Throws:
      java.lang.NullPointerException - if the item could not get read
    • readJsonMessage

      public JsonMessage readJsonMessage​(int maxLength)
    • getBuffer

      public io.netty.buffer.ByteBuf getBuffer()
    • read

      public int read()
      Specified by:
      read in class java.io.InputStream
    • available

      public int available()
      Overrides:
      available in class java.io.InputStream
    • readTag

      public org.jglrxavpok.hephaistos.nbt.NBT readTag() throws java.io.IOException, org.jglrxavpok.hephaistos.nbt.NBTException
      Throws:
      java.io.IOException
      org.jglrxavpok.hephaistos.nbt.NBTException