public class NBTReflectionUtil extends Object
NbtApiException
Modifier and Type | Method and Description |
---|---|
static void |
addNBTTagCompound(NBTCompound comp,
String name)
Creates a subCompound with a given name in the given NMS Compound
|
static Object |
convertNBTCompoundtoNMSItem(NBTCompound nbtcompound)
Converts
NBTCompound to NMS ItemStacks |
static NBTContainer |
convertNMSItemtoNBTCompound(Object nmsitem)
Converts NMS ItemStacks to
NBTContainer |
static Object |
getCraftItemHandle(org.bukkit.inventory.ItemStack item)
Gets the nms handle ItemStack from a CraftItemStack.
|
static Object |
getData(NBTCompound comp,
ReflectionMethod type,
String key)
Gets data from the Compound
|
static Object |
getEntityNBTTagCompound(Object nmsEntity)
Gets the Vanilla NBT Compound from a given NMS Entity
|
static Object |
getEntry(NBTCompound comp,
String key) |
static Object |
getItemRootNBTTagCompound(Object nmsitem)
Simulates getOrCreateTag.
|
static Set<String> |
getKeys(NBTCompound comp)
Gets the Keyset inside this Compound
|
static <T> NBTList<T> |
getList(NBTCompound comp,
String key,
NBTType type,
Class<T> clazz)
Returns the List saved with a given key.
|
static NBTType |
getListType(NBTCompound comp,
String key) |
static Object |
getNMSEntity(org.bukkit.entity.Entity entity)
Gets the NMS Entity for a given Bukkit Entity
|
static <T> T |
getObject(NBTCompound comp,
String key,
Class<T> type)
Uses Gson to load back a
Serializable object from the Compound |
static Object |
getSubNBTTagCompound(Object compound,
String name)
Gets the subCompound with a given name from a NMS Compound
|
static Object |
getTileEntityNBTTagCompound(org.bukkit.block.BlockState tile)
Gets the NMS Compound from a given TileEntity
|
static Object |
getToCompount(Object nbttag,
NBTCompound comp) |
static Map<String,Object> |
getUnhandledNBTTags(org.bukkit.inventory.meta.ItemMeta meta)
Deprecated.
|
static void |
mergeOtherNBTCompound(NBTCompound comp,
NBTCompound nbtcompoundSrc)
Merges the second
NBTCompound into the first one |
static Object |
readNBT(InputStream stream)
Reads in a InputStream as NMS Compound
|
static void |
remove(NBTCompound comp,
String key)
Deletes the given key
|
static void |
set(NBTCompound comp,
String key,
Object val)
Sets a key in a
NBTCompound to a given value |
static void |
setData(NBTCompound comp,
ReflectionMethod type,
String key,
Object data)
Sets data inside the Compound
|
static Object |
setEntityNBTTag(Object nbtTag,
Object nmsEntity)
Loads all Vanilla tags from a NMS Compound into a NMS Entity
|
static void |
setItemStackCompound(Object nmsItem,
Object compound)
Set the Compound as the Items NBT or CustomData
|
static void |
setObject(NBTCompound comp,
String key,
Object value)
Uses Gson to set a
Serializable value in a Compound |
static void |
setTileEntityNBTTagCompound(org.bukkit.block.BlockState tile,
Object comp)
Sets Vanilla tags from a NMS Compound to a TileEntity
|
static boolean |
valideCompound(NBTCompound comp)
Checks if the Compound is correctly linked to it's roots
|
static void |
writeApiNBT(NBTCompound comp,
OutputStream stream)
Writes a Compound to an OutputStream
|
static Object |
writeNBT(Object nbt,
OutputStream stream)
Writes a NMS Compound to an OutputStream
|
public static Object getNMSEntity(org.bukkit.entity.Entity entity)
entity
- Bukkit Entitypublic static Object readNBT(InputStream stream)
stream
- InputStream of any NBT filepublic static Object writeNBT(Object nbt, OutputStream stream)
nbt
- NMS Compoundstream
- Stream to write topublic static Object getCraftItemHandle(org.bukkit.inventory.ItemStack item)
item
- public static void writeApiNBT(NBTCompound comp, OutputStream stream)
comp
- Compoundstream
- Stream to write topublic static Object getItemRootNBTTagCompound(Object nmsitem)
nmsitem
- public static void setItemStackCompound(Object nmsItem, Object compound)
nmsItem
- compound
- public static Object convertNBTCompoundtoNMSItem(NBTCompound nbtcompound)
NBTCompound
to NMS ItemStacksnbtcompound
- Any valid NBTCompound
public static NBTContainer convertNMSItemtoNBTCompound(Object nmsitem)
NBTContainer
nmsitem
- NMS ItemStackNBTContainer
with all the data@Deprecated public static Map<String,Object> getUnhandledNBTTags(org.bukkit.inventory.meta.ItemMeta meta)
meta
- ItemMeta from which tags should be retrievedpublic static Object getEntityNBTTagCompound(Object nmsEntity)
nmsEntity
- public static Object setEntityNBTTag(Object nbtTag, Object nmsEntity)
nbtTag
- nmsEntity
- public static Object getTileEntityNBTTagCompound(org.bukkit.block.BlockState tile)
tile
- public static void setTileEntityNBTTagCompound(org.bukkit.block.BlockState tile, Object comp)
tile
- comp
- public static Object getSubNBTTagCompound(Object compound, String name)
compound
- name
- public static void addNBTTagCompound(NBTCompound comp, String name)
comp
- name
- public static boolean valideCompound(NBTCompound comp)
comp
- public static Object getToCompount(Object nbttag, NBTCompound comp)
public static void mergeOtherNBTCompound(NBTCompound comp, NBTCompound nbtcompoundSrc)
NBTCompound
into the first onecomp
- Target for the mergenbtcompoundSrc
- Data to mergepublic static void set(NBTCompound comp, String key, Object val)
NBTCompound
to a given valuecomp
- key
- val
- public static <T> NBTList<T> getList(NBTCompound comp, String key, NBTType type, Class<T> clazz)
comp
- key
- type
- clazz
- public static NBTType getListType(NBTCompound comp, String key)
public static Object getEntry(NBTCompound comp, String key)
public static void setObject(NBTCompound comp, String key, Object value)
Serializable
value in a Compoundcomp
- key
- value
- public static <T> T getObject(NBTCompound comp, String key, Class<T> type)
Serializable
object from the Compoundcomp
- key
- type
- public static void remove(NBTCompound comp, String key)
comp
- key
- public static Set<String> getKeys(NBTCompound comp)
comp
- public static void setData(NBTCompound comp, ReflectionMethod type, String key, Object data)
comp
- type
- key
- data
- public static Object getData(NBTCompound comp, ReflectionMethod type, String key)
comp
- type
- key
- Copyright © 2015–2024 tr7zw. All rights reserved.