Package net.glowstone.util.mojangson
Class Mojangson
java.lang.Object
net.glowstone.util.mojangson.Mojangson
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
fromGenericTag
(Tag tag) Creates a Mojangson string from the given NBT Tag.static String
fromTag
(ByteArrayTag tag) Creates a Mojangson string from the given ByteArray Tag.static String
Creates a Mojangson string from the given Byte Tag.static String
fromTag
(CompoundTag tag) Creates a Mojangson string from the given Compound Tag.static String
Creates a Mojangson string from the given Double Tag.static String
Creates a Mojangson string from the given Float Tag.static String
fromTag
(IntArrayTag tag) Creates a Mojangson string from the given IntArray Tag.static String
Creates a Mojangson string from the given Int Tag.static String
Creates a Mojangson string from the given List Tag.static String
fromTag
(LongArrayTag tag) Creates a Mojangson string from the given LongArray Tag.static String
Creates a Mojangson string from the given Long Tag.static String
Creates a Mojangson string from the given Short Tag.static String
Creates a Mojangson string from the given String Tag.static Tag
parseArray
(String mojangson) Parses an Array value from a Mojangson string.static ByteTag
Parses a Byte value from a Mojangson string as an NBT ByteTag.static CompoundTag
parseCompound
(String mojangson) Parses a Compound from a Mojangson string as an NBT CompoundTag.static DoubleTag
parseDouble
(String mojangson) Parses a Double value from a Mojangson string as an NBT DoubleTag.static FloatTag
parseFloat
(String mojangson) Parses a Float value from a Mojangson string as an NBT FloatTag.static IntTag
Parses an Integer value from a Mojangson string as an NBT IntTag.static LongTag
Parses a Long value from a Mojangson string as an NBT LongTag.static ShortTag
parseShort
(String mojangson) Parses a Short value from a Mojangson string as an NBT ShortTag.static StringTag
parseString
(String mojangson) Parses an String value from a Mojangson string as an NBT StringTag.static Tag
Detects 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
-