public class NBTCompound extends Object implements ReadWriteNBT
NBTContainer| Modifier | Constructor and Description |
|---|---|
protected |
NBTCompound(NBTCompound owner,
String name) |
protected |
NBTCompound(NBTCompound owner,
String name,
boolean readOnly) |
| Modifier and Type | Method and Description |
|---|---|
NBTCompound |
addCompound(String name)
Creates a subCompound, or returns it if already provided
|
String |
asNBTString()
Deprecated.
Just use toString()
|
void |
clearNBT()
Remove all keys from this compound
|
boolean |
equals(Object obj)
Does a deep compare to check if everything is the same
|
NBTCompound |
extractDifference(ReadableNBT other)
Compares this readable nbt to the other one
and returns the difference.
|
<T> T |
get(String key,
NBTHandler<T> handler)
Get the object at the specified key via the handler.
|
Boolean |
getBoolean(String key)
Getter
|
Byte |
getByte(String key)
Getter
|
byte[] |
getByteArray(String key)
Getter
|
Object |
getCompound() |
NBTCompound |
getCompound(String name) |
NBTCompoundList |
getCompoundList(String name) |
Double |
getDouble(String key)
Getter
|
NBTList<Double> |
getDoubleList(String name) |
<E extends Enum<E>> |
getEnum(String key,
Class<E> type)
Get an Enum value that has been set via setEnum or setString(key,
value.name()).
|
Float |
getFloat(String key)
Getter
|
NBTList<Float> |
getFloatList(String name) |
int[] |
getIntArray(String key)
Getter
|
NBTList<int[]> |
getIntArrayList(String name) |
Integer |
getInteger(String key)
Getter
|
NBTList<Integer> |
getIntegerList(String name) |
org.bukkit.inventory.ItemStack |
getItemStack(String key)
Get an ItemStack that was saved at the given key
|
org.bukkit.inventory.ItemStack[] |
getItemStackArray(String key)
Get an
ItemStack array that was saved at the given key, or null if no
stored data was found |
Set<String> |
getKeys() |
NBTType |
getListType(String name)
Returns the type of the list, null if not a list
|
Long |
getLong(String key)
Getter
|
long[] |
getLongArray(String key)
Getter
Requires at least 1.16
|
NBTList<Long> |
getLongList(String name) |
String |
getName() |
<T> T |
getObject(String key,
Class<T> type)
Deprecated.
|
NBTCompound |
getOrCreateCompound(String name)
The same as addCompound, just with a name that better reflects what it does
|
<T> T |
getOrDefault(String key,
T defaultValue)
Returns the stored value if exists, or provided value otherwise.
|
<T> T |
getOrNull(String key,
Class<?> type)
Returns the stored value if exists, or null.
|
NBTCompound |
getParent() |
protected Lock |
getReadLock() |
protected Object |
getResolvedObject() |
Short |
getShort(String key)
Getter
|
String |
getString(String key)
Getter
|
NBTList<String> |
getStringList(String name) |
NBTType |
getType(String name) |
UUID |
getUUID(String key)
Getter
|
NBTList<UUID> |
getUUIDList(String name) |
protected Lock |
getWriteLock() |
int |
hashCode() |
Boolean |
hasKey(String key)
Deprecated.
Use
hasTag(String) instead |
boolean |
hasTag(String key)
Checks whether the provided key exists
|
protected boolean |
isClosed() |
protected boolean |
isReadOnly() |
void |
mergeCompound(NBTCompound comp)
Merges all data from comp into this compound.
|
void |
mergeCompound(ReadableNBT comp)
Merges all data from comp into this compound.
|
void |
removeKey(String key) |
ReadWriteNBT |
resolveCompound(String key)
Returns the resolved Compound if exists, or null.
|
ReadWriteNBT |
resolveOrCreateCompound(String key)
Returns the resolved and creates compounds as required.
|
<T> T |
resolveOrDefault(String key,
T defaultValue)
Returns the resolved value if exists, or provided value otherwise.
|
<T> T |
resolveOrNull(String key,
Class<?> type)
Returns the resolved value if exists, or null.
|
protected void |
saveCompound() |
protected void |
set(String key,
Object val) |
<T> void |
set(String key,
T value,
NBTHandler<T> handler)
Set an Object to a key via the provided handler.
|
void |
setBoolean(String key,
Boolean value)
Setter
|
void |
setByte(String key,
Byte value)
Setter
|
void |
setByteArray(String key,
byte[] value)
Setter
|
protected void |
setClosed() |
protected void |
setCompound(Object compound) |
void |
setDouble(String key,
Double value)
Setter
|
<E extends Enum<?>> |
setEnum(String key,
E value)
Set a key to the given Enum value.
|
void |
setFloat(String key,
Float value)
Setter
|
void |
setIntArray(String key,
int[] value)
Setter
|
void |
setInteger(String key,
Integer value)
Setter
|
void |
setItemStack(String key,
org.bukkit.inventory.ItemStack item)
Save an ItemStack as a compound under a given key
|
void |
setItemStackArray(String key,
org.bukkit.inventory.ItemStack[] items)
Save an ItemStack Array as a compound under a given key
|
void |
setLong(String key,
Long value)
Setter
|
void |
setLongArray(String key,
long[] value)
Setter
Requires at least 1.16
|
void |
setObject(String key,
Object value)
Deprecated.
|
protected void |
setResolvedObject(Object object) |
void |
setShort(String key,
Short value)
Setter
|
void |
setString(String key,
String value)
Setter
|
void |
setUUID(String key,
UUID value)
Setter
|
String |
toString() |
String |
toString(String key)
Deprecated.
Just use toString()
|
void |
writeCompound(OutputStream stream)
Write the content of this Compound into the provided stream.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waithasTagprotected NBTCompound(NBTCompound owner, String name)
protected NBTCompound(NBTCompound owner, String name, boolean readOnly)
protected Lock getReadLock()
protected Lock getWriteLock()
protected void saveCompound()
protected void setResolvedObject(Object object)
protected void setClosed()
protected boolean isClosed()
protected boolean isReadOnly()
protected Object getResolvedObject()
public String getName()
public Object getCompound()
protected void setCompound(Object compound)
public NBTCompound getParent()
public void mergeCompound(NBTCompound comp)
comp - public void mergeCompound(ReadableNBT comp)
ReadWriteNBTmergeCompound in interface ReadWriteNBTpublic void setString(String key, String value)
setString in interface ReadWriteNBTkey - value - public String getString(String key)
getString in interface ReadableNBTkey - public void setInteger(String key, Integer value)
setInteger in interface ReadWriteNBTkey - value - public Integer getInteger(String key)
getInteger in interface ReadableNBTkey - public void setDouble(String key, Double value)
setDouble in interface ReadWriteNBTkey - value - public Double getDouble(String key)
getDouble in interface ReadableNBTkey - public void setByte(String key, Byte value)
setByte in interface ReadWriteNBTkey - value - public Byte getByte(String key)
getByte in interface ReadableNBTkey - public void setShort(String key, Short value)
setShort in interface ReadWriteNBTkey - value - public Short getShort(String key)
getShort in interface ReadableNBTkey - public void setLong(String key, Long value)
setLong in interface ReadWriteNBTkey - value - public Long getLong(String key)
getLong in interface ReadableNBTkey - public void setFloat(String key, Float value)
setFloat in interface ReadWriteNBTkey - value - public Float getFloat(String key)
getFloat in interface ReadableNBTkey - public void setByteArray(String key, byte[] value)
setByteArray in interface ReadWriteNBTkey - value - public byte[] getByteArray(String key)
getByteArray in interface ReadableNBTkey - public void setIntArray(String key, int[] value)
setIntArray in interface ReadWriteNBTkey - value - public int[] getIntArray(String key)
getIntArray in interface ReadableNBTkey - public void setLongArray(String key, long[] value)
setLongArray in interface ReadWriteNBTkey - value - public long[] getLongArray(String key)
getLongArray in interface ReadableNBTkey - public void setBoolean(String key, Boolean value)
setBoolean in interface ReadWriteNBTkey - value - public Boolean getBoolean(String key)
getBoolean in interface ReadableNBTkey - @Deprecated public void setObject(String key, Object value)
Serializable Object. Deprecated to clarify that
it's probably missused. Preferably do the serializing yourself.key - value - @Deprecated public <T> T getObject(String key, Class<T> type)
key - type - Class of the Objectpublic void setItemStack(String key, org.bukkit.inventory.ItemStack item)
setItemStack in interface ReadWriteNBTkey - item - public org.bukkit.inventory.ItemStack getItemStack(String key)
getItemStack in interface ReadableNBTkey - public void setItemStackArray(String key, org.bukkit.inventory.ItemStack[] items)
setItemStackArray in interface ReadWriteNBTkey - items - public org.bukkit.inventory.ItemStack[] getItemStackArray(String key)
ItemStack array that was saved at the given key, or null if no
stored data was foundgetItemStackArray in interface ReadableNBTkey - keyItemStack array, or null if stored data wasn't
foundpublic void setUUID(String key, UUID value)
setUUID in interface ReadWriteNBTkey - value - public UUID getUUID(String key)
getUUID in interface ReadableNBTkey - @Deprecated public Boolean hasKey(String key)
hasTag(String) insteadkey - String keypublic boolean hasTag(String key)
hasTag in interface ReadableNBTkey - String keypublic void removeKey(String key)
removeKey in interface ReadWriteNBTkey - Deletes the given Keypublic Set<String> getKeys()
getKeys in interface ReadableNBTpublic NBTCompound addCompound(String name)
name - Key to usepublic NBTCompound getCompound(String name)
getCompound in interface ReadableNBTgetCompound in interface ReadWriteNBTname - public NBTCompound getOrCreateCompound(String name)
getOrCreateCompound in interface ReadWriteNBTname - public NBTList<String> getStringList(String name)
getStringList in interface ReadableNBTgetStringList in interface ReadWriteNBTname - public NBTList<Integer> getIntegerList(String name)
getIntegerList in interface ReadableNBTgetIntegerList in interface ReadWriteNBTname - public NBTList<int[]> getIntArrayList(String name)
getIntArrayList in interface ReadableNBTgetIntArrayList in interface ReadWriteNBTname - public NBTList<UUID> getUUIDList(String name)
getUUIDList in interface ReadableNBTgetUUIDList in interface ReadWriteNBTname - public NBTList<Float> getFloatList(String name)
getFloatList in interface ReadableNBTgetFloatList in interface ReadWriteNBTname - public NBTList<Double> getDoubleList(String name)
getDoubleList in interface ReadableNBTgetDoubleList in interface ReadWriteNBTname - public NBTList<Long> getLongList(String name)
getLongList in interface ReadableNBTgetLongList in interface ReadWriteNBTname - public NBTType getListType(String name)
getListType in interface ReadableNBTname - public NBTCompoundList getCompoundList(String name)
getCompoundList in interface ReadableNBTgetCompoundList in interface ReadWriteNBTname - public <T> T getOrDefault(String key, T defaultValue)
Supported types:
Boolean, Byte, Short, Integer, Long, Float, Double, byte[], int[], long[],
String, UUID, and Enum
getOrDefault in interface ReadableNBTT - value typekey - keydefaultValue - default non-null valuepublic <T> T getOrNull(String key, Class<?> type)
Supported types:
Boolean, Byte, Short, Integer, Long, Float, Double, byte[], int[], long[],
String, UUID, and Enum
getOrNull in interface ReadableNBTT - value typekey - keytype - data typepublic <T> T resolveOrNull(String key, Class<?> type)
ReadableNBT
Supported types:
Boolean, Byte, Short, Integer, Long, Float, Double, byte[], int[], long[],
String, UUID, and Enum
resolveOrNull in interface ReadableNBTT - value typekey - Path key, seperated by '.'. For example: "foo.bar.baz". Dots can
be escaped with a backslash.type - data typepublic <T> T resolveOrDefault(String key, T defaultValue)
ReadableNBT
Supported types:
Boolean, Byte, Short, Integer, Long, Float, Double, byte[], int[], long[],
String, UUID, and Enum
resolveOrDefault in interface ReadableNBTT - value typekey - Path key, seperated by '.'. For example: "foo.bar.baz".
Dots can be escaped with a backslash.defaultValue - default non-null valuepublic ReadWriteNBT resolveCompound(String key)
ReadableNBTresolveCompound in interface ReadableNBTresolveCompound in interface ReadWriteNBTkey - Path key, seperated by '.'. For example: "foo.bar.baz". Dots can
be escaped with a backslash.public ReadWriteNBT resolveOrCreateCompound(String key)
ReadWriteNBTresolveOrCreateCompound in interface ReadWriteNBTkey - Path key, seperated by '.'. For example: "foo.bar.baz". Dots can
be escaped with a backslash.public <E extends Enum<?>> void setEnum(String key, E value)
setEnum in interface ReadWriteNBTE - key - value - public <E extends Enum<E>> E getEnum(String key, Class<E> type)
getEnum in interface ReadableNBTE - key - type - public NBTType getType(String name)
getType in interface ReadableNBTname - public void writeCompound(OutputStream stream)
ReadableNBTwriteCompound in interface ReadableNBTpublic <T> T get(String key, NBTHandler<T> handler)
ReadableNBTget in interface ReadableNBTpublic <T> void set(String key, T value, NBTHandler<T> handler)
ReadWriteNBTset in interface ReadWriteNBTpublic String toString()
toString in interface ReadableNBTtoString in class Object@Deprecated public String toString(String key)
key - public void clearNBT()
clearNBT in interface ReadWriteNBT@Deprecated public String asNBTString()
String representation of the NBT in Mojang JSON. This is
different from normal JSON!public boolean equals(Object obj)
public NBTCompound extractDifference(ReadableNBT other)
ReadableNBTNote: the result will only contain data that is present in this readable nbt and is missing/different in the provided one.
extractDifference in interface ReadableNBTother - other readable nbtCopyright © 2015–2025 tr7zw. All rights reserved.