Package net.glowstone.util.mojangson
Class Mojangson
java.lang.Object
net.glowstone.util.mojangson.Mojangson
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringfromGenericTag(Tag tag) Creates a Mojangson string from the given NBT Tag.static StringfromTag(ByteArrayTag tag) Creates a Mojangson string from the given ByteArray Tag.static StringCreates a Mojangson string from the given Byte Tag.static StringfromTag(CompoundTag tag) Creates a Mojangson string from the given Compound Tag.static StringCreates a Mojangson string from the given Double Tag.static StringCreates a Mojangson string from the given Float Tag.static StringfromTag(IntArrayTag tag) Creates a Mojangson string from the given IntArray Tag.static StringCreates a Mojangson string from the given Int Tag.static StringCreates a Mojangson string from the given List Tag.static StringfromTag(LongArrayTag tag) Creates a Mojangson string from the given LongArray Tag.static StringCreates a Mojangson string from the given Long Tag.static StringCreates a Mojangson string from the given Short Tag.static StringCreates a Mojangson string from the given String Tag.static TagparseArray(String mojangson) Parses an Array value from a Mojangson string.static ByteTagParses a Byte value from a Mojangson string as an NBT ByteTag.static CompoundTagparseCompound(String mojangson) Parses a Compound from a Mojangson string as an NBT CompoundTag.static DoubleTagparseDouble(String mojangson) Parses a Double value from a Mojangson string as an NBT DoubleTag.static FloatTagparseFloat(String mojangson) Parses a Float value from a Mojangson string as an NBT FloatTag.static IntTagParses an Integer value from a Mojangson string as an NBT IntTag.static LongTagParses a Long value from a Mojangson string as an NBT LongTag.static ShortTagparseShort(String mojangson) Parses a Short value from a Mojangson string as an NBT ShortTag.static StringTagparseString(String mojangson) Parses an String value from a Mojangson string as an NBT StringTag.static TagDetects the Tag type of the Mojangson string, and parses it.
-
Method Details
-
parseTag
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
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
Parses an String value from a Mojangson string as an NBT StringTag.- Parameters:
mojangson- The Mojangson string- Returns:
- the parsed StringTag NBT value
-
parseLong
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
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
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
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
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
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
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
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
Creates a Mojangson string from the given Byte Tag.- Parameters:
tag- the Byte Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given ByteArray Tag.- Parameters:
tag- the ByteArray Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given Compound Tag.- Parameters:
tag- the Compound Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given Double Tag.- Parameters:
tag- the Double Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given Float Tag.- Parameters:
tag- the Float Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given Int Tag.- Parameters:
tag- the Int Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given IntArray Tag.- Parameters:
tag- the IntArray Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given List Tag.- Parameters:
tag- the List Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given Long Tag.- Parameters:
tag- the Long Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given Short Tag.- Parameters:
tag- the Short Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given String Tag.- Parameters:
tag- the String Tag to convert- Returns:
- the converted Mojangson string
-
fromTag
Creates a Mojangson string from the given LongArray Tag.- Parameters:
tag- the LongArray Tag to convert- Returns:
- the converted Mojangson string
-