Interface NbtCompound
Use NbtFactory to load or create an instance.
The NbtBase.getValue() method returns a Map that will return the full content
of this NBT compound, but may throw an UnsupportedOperationException for any of the write operations.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Determine if an entry with the given key exists or not.byteRetrieve the byte value of an entry identified by a given key.byte[]getByteArray(String key) Retrieve the byte array value of an entry identified by a given key.bytegetByteOrDefault(String key) Retrieve the byte value of an existing entry, or from a new default entry if it doesn't exist.getCompound(String key) Retrieve the compound (map) value of an entry identified by a given key.Retrieve a compound (map) value by its key, or create a new compound if it doesn't exist.doubleRetrieve the double value of an entry identified by a given key.doublegetDoubleOrDefault(String key) Retrieve the double value of an existing entry, or from a new default entry if it doesn't exist.floatRetrieve the float value of an entry identified by a given key.floatgetFloatOrDefault(String key) Retrieve the float value of an existing entry, or from a new default entry if it doesn't exist.intgetInteger(String key) Retrieve the integer value of an entry identified by a given key.int[]getIntegerArray(String key) Retrieve the integer array value of an entry identified by a given key.intRetrieve the integer value of an existing entry, or from a new default entry if it doesn't exist.getKeys()Retrieve a Set view of the keys of each entry in this compound.<T> NbtList<T> Retrieve the NBT list value of an entry identified by a given key.<T> NbtList<T> getListOrDefault(String key) Retrieve a NBT list value by its key, or create a new list if it doesn't exist.longRetrieve the long value of an entry identified by a given key.longgetLongOrDefault(String key) Retrieve the long value of an existing entry, or from a new default entry if it doesn't exist.Retrieve the primitive object, NbtList or NbtCompound associated with the given key.Retrieve the short value of an entry identified by a given key.shortgetShortOrDefault(String key) Retrieve the short value of an existing entry, or from a new default entry if it doesn't exist.Retrieve the string value of an entry identified by a given key.getStringOrDefault(String key) Retrieve the string value of an existing entry, or from a new default entry if it doesn't exist.getValue()Deprecated.<T> NbtBase<T> Retrieve the value of a given entry.NbtBase<?> getValueOrDefault(String key, NbtType type) Retrieve a value by its key, or assign and return a new NBT element if it doesn't exist.iterator()Retrieve an iterator view of the NBT tags stored in this compound.<T> NbtCompoundSet a entry based on its name.put(NbtCompound compound) Associate a NBT compound with its name as key.<T> NbtCompoundAssociate a NBT list with the given key.Associate a NBT byte value with the given key.Associate a NBT byte array value with the given key.Associate a NBT double value with the given key.Associate a NBT float value with the given key.Associate a NBT integer value with the given key.Associate a NBT integer array value with the given key.Associate a NBT long value with the given key.Associate a NBT short value with the given key.Inserts an entry after cloning it and renaming it to "key".Associate a NBT string value with the given key.<T> NbtCompoundput(String key, Collection<? extends NbtBase<T>> list) Associate a new NBT list with the given key.Associates a given Java primitive value, list, map or NbtBase with a certain key.<T> NbtBase<?> Remove the NBT element that is associated with the given key.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
getValue
Deprecated.Description copied from interface:NbtBaseRetrieve the value of this NBT tag.Is either a primitive
wrapper,String,Listor aMap.Users are encouraged to cast an NBT compound to
NbtCompoundand use its put and get-methods instead of accessing its content from getValue().All operations that modify collections directly, such as
List.add(Object)orMap.clear(), are considered optional. This also include members inIteratorandListIterator. Operations that are not implemented throw aUnsupportedOperationException. -
containsKey
Determine if an entry with the given key exists or not.- Parameters:
key- - the key to lookup.- Returns:
- TRUE if an entry with the given key exists, FALSE otherwise.
-
getKeys
Retrieve a Set view of the keys of each entry in this compound.- Returns:
- The keys of each entry.
-
getValue
Retrieve the value of a given entry.- Type Parameters:
T- Type- Parameters:
key- - key of the entry to retrieve.- Returns:
- The value of this entry, or NULL if not found.
-
getValueOrDefault
Retrieve a value by its key, or assign and return a new NBT element if it doesn't exist.- Parameters:
key- - the key of the entry to find or create.type- - the NBT element we will create if not found.- Returns:
- The value that was retrieved or just created.
-
put
Set a entry based on its name.- Type Parameters:
T- Type- Parameters:
entry- - entry with a name and value.- Returns:
- This compound, for chaining.
- Throws:
IllegalArgumentException- If entry is NULL.
-
getString
Retrieve the string value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The string value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getStringOrDefault
Retrieve the string value of an existing entry, or from a new default entry if it doesn't exist.- Parameters:
key- - the key of the entry.- Returns:
- The value that was retrieved or just created.
-
put
Associate a NBT string value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
put
Inserts an entry after cloning it and renaming it to "key".- Parameters:
key- - the name of the entry.entry- - the entry to insert.- Returns:
- This current compound, for chaining.
-
getByte
Retrieve the byte value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The byte value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getByteOrDefault
Retrieve the byte value of an existing entry, or from a new default entry if it doesn't exist.- Parameters:
key- - the key of the entry.- Returns:
- The value that was retrieved or just created.
-
put
Associate a NBT byte value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
getShort
Retrieve the short value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The short value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getShortOrDefault
Retrieve the short value of an existing entry, or from a new default entry if it doesn't exist.- Parameters:
key- - the key of the entry.- Returns:
- The value that was retrieved or just created.
-
put
Associate a NBT short value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
getInteger
Retrieve the integer value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The integer value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getIntegerOrDefault
Retrieve the integer value of an existing entry, or from a new default entry if it doesn't exist.- Parameters:
key- - the key of the entry.- Returns:
- The value that was retrieved or just created.
-
put
Associate a NBT integer value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
getLong
Retrieve the long value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The long value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getLongOrDefault
Retrieve the long value of an existing entry, or from a new default entry if it doesn't exist.- Parameters:
key- - the key of the entry.- Returns:
- The value that was retrieved or just created.
-
put
Associate a NBT long value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
getFloat
Retrieve the float value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The float value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getFloatOrDefault
Retrieve the float value of an existing entry, or from a new default entry if it doesn't exist.- Parameters:
key- - the key of the entry.- Returns:
- The value that was retrieved or just created.
-
put
Associate a NBT float value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
getDouble
Retrieve the double value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The double value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getDoubleOrDefault
Retrieve the double value of an existing entry, or from a new default entry if it doesn't exist.- Parameters:
key- - the key of the entry.- Returns:
- The value that was retrieved or just created.
-
put
Associate a NBT double value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
getByteArray
Retrieve the byte array value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The byte array value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
put
Associate a NBT byte array value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
getIntegerArray
Retrieve the integer array value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The integer array value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
put
Associate a NBT integer array value with the given key.- Parameters:
key- - the key and NBT name.value- - the value.- Returns:
- This current compound, for chaining.
-
putObject
Associates a given Java primitive value, list, map or NbtBase with a certain key.If the value is NULL, the corresponding key is removed. Any Map or List will be converted to a corresponding NbtCompound or NbtList.
- Parameters:
key- - the name of the new entry,value- - the value of the new entry, or NULL to remove the current value.- Returns:
- This current compound, for chaining.
-
getObject
Retrieve the primitive object, NbtList or NbtCompound associated with the given key.- Parameters:
key- - the key of the object to find.- Returns:
- The object with this key, or NULL if we couldn't find anything.
-
getCompound
Retrieve the compound (map) value of an entry identified by a given key.- Parameters:
key- - the key of the entry.- Returns:
- The compound value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getCompoundOrDefault
Retrieve a compound (map) value by its key, or create a new compound if it doesn't exist.- Parameters:
key- - the key of the entry to find or create.- Returns:
- The compound value that was retrieved or just created.
-
put
Associate a NBT compound with its name as key.- Parameters:
compound- - the compound value.- Returns:
- This current compound, for chaining.
-
getList
Retrieve the NBT list value of an entry identified by a given key.- Type Parameters:
T- Type- Parameters:
key- - the key of the entry.- Returns:
- The NBT list value of the entry.
- Throws:
IllegalArgumentException- If the key doesn't exist.
-
getListOrDefault
Retrieve a NBT list value by its key, or create a new list if it doesn't exist.- Type Parameters:
T- Type- Parameters:
key- - the key of the entry to find or create.- Returns:
- The compound value that was retrieved or just created.
-
put
Associate a NBT list with the given key.- Type Parameters:
T- Type- Parameters:
list- - the list value.- Returns:
- This current compound, for chaining.
-
put
Associate a new NBT list with the given key.- Type Parameters:
T- Type- Parameters:
key- - the key and name of the new NBT list.list- - the list of NBT elements.- Returns:
- This current compound, for chaining.
-
remove
Remove the NBT element that is associated with the given key.- Type Parameters:
T- Type- Parameters:
key- - the key of the element to remove.- Returns:
- The removed element, or NULL if no such element was found.
-
iterator
Retrieve an iterator view of the NBT tags stored in this compound.
-