Class NbtTextSerializer

java.lang.Object
com.comphenix.protocol.wrappers.nbt.io.NbtTextSerializer

public class NbtTextSerializer extends Object
Serializes NBT to a base-64 encoded string and back.
  • Field Details

    • DEFAULT

      public static final NbtTextSerializer DEFAULT
      A default instance of this serializer.
  • Constructor Details

    • NbtTextSerializer

      public NbtTextSerializer()
    • NbtTextSerializer

      public NbtTextSerializer(NbtBinarySerializer binary)
      Construct a serializer with a custom binary serializer.
      Parameters:
      binary - - binary serializer.
  • Method Details

    • getBinarySerializer

      public NbtBinarySerializer getBinarySerializer()
      Retrieve the binary serializer that is used.
      Returns:
      The binary serializer.
    • serialize

      public <TType> String serialize(NbtBase<TType> value)
      Serialize a NBT tag to a base-64 encoded string.
      Type Parameters:
      TType - Type
      Parameters:
      value - - the NBT tag to serialize.
      Returns:
      The NBT tag in base-64 form.
    • deserialize

      public <TType> NbtWrapper<TType> deserialize(String input) throws IOException
      Deserialize a NBT tag from a base-64 encoded string.
      Type Parameters:
      TType - Type
      Parameters:
      input - - the base-64 string.
      Returns:
      The NBT tag contained in the string.
      Throws:
      IOException - If we are unable to parse the input.
    • deserializeCompound

      public NbtCompound deserializeCompound(String input) throws IOException
      Deserialize a NBT compound from a base-64 encoded string.
      Parameters:
      input - - the base-64 string.
      Returns:
      The NBT tag contained in the string.
      Throws:
      IOException - If we are unable to parse the input.
    • deserializeList

      public <T> NbtList<T> deserializeList(String input) throws IOException
      Deserialize a NBT list from a base-64 encoded string.
      Type Parameters:
      T - Type
      Parameters:
      input - - the base-64 string.
      Returns:
      The NBT tag contained in the string.
      Throws:
      IOException - If we are unable to parse the input.