Class Mojangson

java.lang.Object
net.glowstone.util.mojangson.Mojangson

public class Mojangson extends Object
  • Method Details

    • parseTag

      public static Tag parseTag(String mojangson) throws MojangsonParseException
      Detects the Tag type of the Mojangson string, and parses it. Convenience method for other parse methods.

      This method will fall back to an IntTag if it could not find an appropriate Tag type, and to String if the value could not be parsed as an Integer either.

      Parameters:
      mojangson - The Mojangson string
      Returns:
      The parsed NBT Tag
      Throws:
      MojangsonParseException - if the given Mojangson string could not be parsed.
    • parseInt

      public static IntTag parseInt(String mojangson) throws MojangsonParseException
      Parses an Integer value from a Mojangson string as an NBT IntTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed IntTag NBT value
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as an Integer value.
    • parseString

      public static StringTag parseString(String mojangson)
      Parses an String value from a Mojangson string as an NBT StringTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed StringTag NBT value
    • parseLong

      public static LongTag parseLong(String mojangson) throws MojangsonParseException
      Parses a Long value from a Mojangson string as an NBT LongTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed LongTag NBT value
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as a Long value.
    • parseDouble

      public static DoubleTag parseDouble(String mojangson) throws MojangsonParseException
      Parses a Double value from a Mojangson string as an NBT DoubleTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed DoubleTag NBT value
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as a Double value.
    • parseFloat

      public static FloatTag parseFloat(String mojangson) throws MojangsonParseException
      Parses a Float value from a Mojangson string as an NBT FloatTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed FloatTag NBT value
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as a Flaot value.
    • parseShort

      public static ShortTag parseShort(String mojangson) throws MojangsonParseException
      Parses a Short value from a Mojangson string as an NBT ShortTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed ShortTag NBT value
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as a Short value.
    • parseByte

      public static ByteTag parseByte(String mojangson) throws MojangsonParseException
      Parses a Byte value from a Mojangson string as an NBT ByteTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed ByteTag NBT value
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as a Byte value.
    • parseCompound

      public static CompoundTag parseCompound(String mojangson) throws MojangsonParseException
      Parses a Compound from a Mojangson string as an NBT CompoundTag.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      the parsed CompoundTag NBT value
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as a Compound value.
    • parseArray

      public static Tag parseArray(String mojangson) throws MojangsonParseException
      Parses an Array value from a Mojangson string.
      Parameters:
      mojangson - The Mojangson string
      Returns:
      a ByteArrayTag value if the array contains byte values, an IntArrayTag value if the array contains int values or a ListTag with the array's elements.
      Throws:
      MojangsonParseException - if the Mojangson string could not be parsed as an Array value.
    • fromGenericTag

      public static String fromGenericTag(Tag tag)
      Creates a Mojangson string from the given NBT Tag. Convenience method for generic tags (Tag).
      Parameters:
      tag - the NBT Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(ByteTag tag)
      Creates a Mojangson string from the given Byte Tag.
      Parameters:
      tag - the Byte Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(ByteArrayTag tag)
      Creates a Mojangson string from the given ByteArray Tag.
      Parameters:
      tag - the ByteArray Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(CompoundTag tag)
      Creates a Mojangson string from the given Compound Tag.
      Parameters:
      tag - the Compound Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(DoubleTag tag)
      Creates a Mojangson string from the given Double Tag.
      Parameters:
      tag - the Double Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(FloatTag tag)
      Creates a Mojangson string from the given Float Tag.
      Parameters:
      tag - the Float Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(IntTag tag)
      Creates a Mojangson string from the given Int Tag.
      Parameters:
      tag - the Int Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(IntArrayTag tag)
      Creates a Mojangson string from the given IntArray Tag.
      Parameters:
      tag - the IntArray Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(ListTag<Tag> tag)
      Creates a Mojangson string from the given List Tag.
      Parameters:
      tag - the List Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(LongTag tag)
      Creates a Mojangson string from the given Long Tag.
      Parameters:
      tag - the Long Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(ShortTag tag)
      Creates a Mojangson string from the given Short Tag.
      Parameters:
      tag - the Short Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(StringTag tag)
      Creates a Mojangson string from the given String Tag.
      Parameters:
      tag - the String Tag to convert
      Returns:
      the converted Mojangson string
    • fromTag

      public static String fromTag(LongArrayTag tag)
      Creates a Mojangson string from the given LongArray Tag.
      Parameters:
      tag - the LongArray Tag to convert
      Returns:
      the converted Mojangson string