public class NBTCompound extends Object implements Map<String,Object>
Map
:put(String, Object)
creates a clone of NBT tag before put:NBTCompound cmp = new NBTCompound(); // cmp = {} cmp.put("foo", "bar"); // cmp = {foo=bar} cmp.put("self", cmp); // cloning cmp before put, cmp = {foo=bar, self={foo=bar}} cmp.get("self"); // result = {foo=bar}
NBTCompound
can not contain empty keys or values (null)NBTCompound
can not contain cross-references.Modifier and Type | Class and Description |
---|---|
class |
NBTCompound.NBTEntrySet |
class |
NBTCompound.NBTValues |
Constructor and Description |
---|
NBTCompound()
Create new empty NBTCompound
|
NBTCompound(Map map)
Convert java
Map to NBTCompound. |
Modifier and Type | Method and Description |
---|---|
Object |
bind(String key,
NBTCompound value)
Put NBTCompound to handle without using cloning.
|
Object |
bind(String key,
NBTList value)
Put NBTList to handle without using cloning.
|
void |
clear() |
NBTCompound |
clone()
Create clone of this NBT compouns
|
NBTCompound |
compound(String key)
Get NBTCompound or create new one
Example: NBTCompound cmp = new NBTCompound().compound("display").list("Lore").add("lore1"); // cmp = {display:{Lore:["lore1"]}} |
boolean |
containsKey(Object key) |
boolean |
containsKey(String key,
byte type)
Check if compound contains key with value of specific type
|
boolean |
containsKey(String key,
Class type)
Check if compound contains key with value of specific type
|
boolean |
containsValue(Object value) |
NBTCompound.NBTEntrySet |
entrySet() |
boolean |
equals(Object t) |
static NBTCompound |
forNBT(Object tag)
Create new instance of NBTCompound by NBTTagCompound
|
static NBTCompound |
forNBTCopy(Object tag)
Create new instance NBTCompound by copy of NBTTagCompound
|
Object |
get(Object key) |
boolean |
getBoolean(String key)
Try to get value and convert to boolean
|
byte |
getByte(String key)
Try to get byte value or convert to byte
|
byte[] |
getByteArray(String key)
Try to get byte[]
|
NBTCompound |
getCompound(String key)
Try to get NBTCompound
|
double |
getDouble(String key)
Try to get double value or convert to double
|
float |
getFloat(String key)
Try to get float value or convert to float
|
Object |
getHandle()
Get original NBTTagCompound.
|
Object |
getHandleCopy()
Get copy of original NBTTagCompound.
|
Map<String,Object> |
getHandleMap()
get Map stored in original NBTTagCompound.
|
int |
getInt(String key)
Try to get int value or convert to int
|
int[] |
getIntArray(String key)
Try to get int[]
|
NBTList |
getList(String key)
Try to get NBTList
|
long |
getLong(String key)
Try to get long value or convert to long
|
short |
getShort(String key)
Try to get short value or convert to short
|
String |
getString(String key)
Try to get string value or convert string
|
boolean |
isEmpty() |
Set<String> |
keySet() |
NBTList |
list(String key)
get NBTList or create new one
Example: NBTCompound cmp = new NBTCompound().compound("display").list("Lore").add("lore1"); // cmp = {display:{Lore:["lore1"]}} |
void |
merge(Map map)
Merge this compound with map.
|
Object |
put(String key,
Object value)
Put the
copy of value to NBTTagCompound |
void |
putAll(Map<? extends String,?> map)
Copies all of the mappings from the map to this NBTTagCompound
|
Object |
remove(Object key) |
int |
size() |
HashMap<String,Object> |
toHashMap()
Convert nbt compound to
HashMap |
<T extends Map<String,Object>> |
toMap(T map)
Convert NBT compound to java
Map |
String |
toString() |
Collection<Object> |
values() |
getClass, hashCode, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
public static NBTCompound forNBT(Object tag)
tag
- instance of net.minecraft.server.NBTTagCompoundpublic static NBTCompound forNBTCopy(Object tag)
tag
- instance of net.minecraft.server.NBTTagCompoundpublic <T extends Map<String,Object>> T toMap(T map)
Map
T
- Tmap
- Empty map to fillpublic HashMap<String,Object> toHashMap()
HashMap
public Object getHandle()
public Object getHandleCopy()
public Map<String,Object> getHandleMap()
public boolean equals(Object t)
public NBTCompound clone()
clone
in class Object
NBTCompound
public boolean containsKey(Object key)
containsKey
in interface Map<String,Object>
public boolean containsValue(Object value)
containsValue
in interface Map<String,Object>
public void putAll(Map<? extends String,?> map)
public NBTCompound.NBTEntrySet entrySet()
public void merge(Map map)
map
- map to mergepublic boolean getBoolean(String key)
key
- keypublic byte getByte(String key)
key
- keypublic short getShort(String key)
key
- keypublic int getInt(String key)
key
- keypublic long getLong(String key)
key
- keypublic float getFloat(String key)
key
- keypublic double getDouble(String key)
key
- keypublic String getString(String key)
key
- keypublic int[] getIntArray(String key)
key
- keypublic byte[] getByteArray(String key)
key
- keypublic NBTCompound getCompound(String key)
key
- keypublic NBTList getList(String key)
key
- keypublic NBTCompound compound(String key)
NBTCompound cmp = new NBTCompound().compound("display").list("Lore").add("lore1"); // cmp = {display:{Lore:["lore1"]}}
key
- Keypublic NBTList list(String key)
NBTCompound cmp = new NBTCompound().compound("display").list("Lore").add("lore1"); // cmp = {display:{Lore:["lore1"]}}
key
- Keypublic Object bind(String key, NBTCompound value)
key
- key with which the NBTCompound is to be associatedvalue
- NBTCompound to be associated with keypublic Object bind(String key, NBTList value)
key
- Key with which the NBTList is to be associatedvalue
- NBTList to be associated with keypublic boolean containsKey(String key, Class type)
key
- keytype
- type of valuepublic boolean containsKey(String key, byte type)
key
- keytype
- byte type of NBT tagCopyright © 2017. All rights reserved.