public class NBT extends Object
Modifier and Type | Method and Description |
---|---|
static ReadWriteNBT |
createNBTObject()
Create a new NBTContainer object and return it.
|
static com.mojang.authlib.GameProfile |
gameProfileFromNBT(ReadableNBT compound)
It takes a NBT compound and returns a GameProfile
|
static ReadWriteNBT |
gameProfileToNBT(com.mojang.authlib.GameProfile profile)
It converts a GameProfile object to a ReadWriteNBT object
|
static void |
get(org.bukkit.block.BlockState blockState,
Consumer<ReadableNBT> getter)
It takes an BlockEntity, and a Consumer that takes a ReadableNBT.
|
static <T> T |
get(org.bukkit.block.BlockState blockState,
Function<ReadableNBT,T> getter)
It takes a block state and a function that takes a readable NBT and returns a
value of type T.
|
static void |
get(org.bukkit.entity.Entity entity,
Consumer<ReadableNBT> getter)
It takes an Entity, and a Consumer that takes a ReadableNBT.
|
static <T> T |
get(org.bukkit.entity.Entity entity,
Function<ReadableNBT,T> getter)
It takes an entity and a function that takes a ReadableNBT and returns a
generic type T, and returns the result of the function
|
static void |
get(org.bukkit.inventory.ItemStack item,
Consumer<ReadableItemNBT> getter)
It takes an ItemStack, and a Consumer that takes a ReadableNBT.
|
static <T> T |
get(org.bukkit.inventory.ItemStack item,
Function<ReadableItemNBT,T> getter)
It takes an ItemStack, and a function that takes a ReadableNBT and returns a
generic type T.
|
static void |
getComponents(org.bukkit.inventory.ItemStack item,
Consumer<ReadableNBT> consumer)
It takes an ItemStack and a Consumer<ReadWriteNBT>, and then applies
the Consumer to the ItemStacks Components as NBT.
|
static <T> T |
getComponents(org.bukkit.inventory.ItemStack item,
Function<ReadableNBT,T> function)
It takes an ItemStack and a Consumer<ReadWriteNBT>, and then applies
the Consumer to the ItemStacks Components as NBT.
|
static NBTFileHandle |
getFileHandle(File file)
Creates a NBTFileHandle that uses @param file to store its data.
|
static <T> T |
getPersistentData(org.bukkit.block.BlockState blockState,
Function<ReadableNBT,T> getter)
It takes a block entity and a function that takes a ReadableNBT and returns a
generic type T, and returns the result of the function, applied to the block
entities persistent data container
|
static <T> T |
getPersistentData(org.bukkit.entity.Entity entity,
Function<ReadableNBT,T> getter)
It takes an entity and a function that takes a ReadableNBT and returns a
generic type T, and returns the result of the function, applied to the
entities persistent data container
|
static org.bukkit.inventory.ItemStack[] |
itemStackArrayFromNBT(ReadableNBT compound)
It converts a ReadableNBT object into an array of ItemStacks
|
static ReadWriteNBT |
itemStackArrayToNBT(org.bukkit.inventory.ItemStack[] itemStacks)
It converts an array of ItemStacks into a ReadWriteNBT object
|
static org.bukkit.inventory.ItemStack |
itemStackFromNBT(ReadableNBT compound)
It converts a ReadableNBT object into an ItemStack
|
static ReadWriteNBT |
itemStackToNBT(org.bukkit.inventory.ItemStack itemStack)
It converts an ItemStack to a ReadWriteNBT object
|
static <X extends NBTProxy> |
modify(org.bukkit.block.BlockState blockState,
Class<X> wrapper,
Consumer<X> consumer)
It takes an block entity and a function to modify the entity via the proxy
|
static <T,X extends NBTProxy> |
modify(org.bukkit.block.BlockState blockState,
Class<X> wrapper,
Function<X,T> function)
It takes an block entity and a function to modify the entity via the proxy
|
static void |
modify(org.bukkit.block.BlockState blockState,
Consumer<ReadWriteNBT> consumer)
It takes a block state and a consumer, and then it creates a new
NBTTileEntity object with the block state, and then it passes that
NBTTileEntity object to the consumer
|
static <T> T |
modify(org.bukkit.block.BlockState blockState,
Function<ReadWriteNBT,T> function)
It takes a block state and a function that takes a ReadWriteNBT and returns a
generic type T.
|
static <X extends NBTProxy> |
modify(org.bukkit.entity.Entity entity,
Class<X> wrapper,
Consumer<X> consumer)
It takes an entity and a function to modify the entity via the proxy
|
static <T,X extends NBTProxy> |
modify(org.bukkit.entity.Entity entity,
Class<X> wrapper,
Function<X,T> function)
It takes an entity and a function to modify the entity via the proxy
|
static void |
modify(org.bukkit.entity.Entity entity,
Consumer<ReadWriteNBT> consumer)
It takes an entity and a function that takes a ReadWriteNBT and applies the
function to the entity
|
static <T> T |
modify(org.bukkit.entity.Entity entity,
Function<ReadWriteNBT,T> function)
It takes an entity and a function that takes a ReadWriteNBT and returns a
generic type T.
|
static <X extends NBTProxy> |
modify(org.bukkit.inventory.ItemStack item,
Class<X> wrapper,
Consumer<X> consumer)
It takes an ItemStack, applies a function to its NBT wrapped in a proxy.
|
static <T,X extends NBTProxy> |
modify(org.bukkit.inventory.ItemStack item,
Class<X> wrapper,
Function<X,T> function)
It takes an ItemStack, applies a function to its NBT wrapped in a proxy, and
returns the result of the function
|
static void |
modify(org.bukkit.inventory.ItemStack item,
Consumer<ReadWriteItemNBT> consumer)
It takes an ItemStack and a Consumer<ReadWriteNBT>, and then applies
the Consumer to the ItemStacks NBT
|
static <T> T |
modify(org.bukkit.inventory.ItemStack item,
Function<ReadWriteItemNBT,T> function)
It takes an ItemStack, applies a function to its NBT, and returns the result
of the function
|
static void |
modifyComponents(org.bukkit.inventory.ItemStack item,
Consumer<ReadWriteNBT> consumer)
It takes an ItemStack and a Consumer<ReadWriteNBT>, and then applies
the Consumer to the ItemStacks Components as NBT.
|
static <T> T |
modifyComponents(org.bukkit.inventory.ItemStack item,
Function<ReadWriteNBT,T> function)
It takes an ItemStack and a Consumer<ReadWriteNBT>, and then applies
the Consumer to the ItemStacks Components as NBT.
|
static void |
modifyPersistentData(org.bukkit.block.BlockState blockState,
Consumer<ReadWriteNBT> consumer)
It takes a block state and a consumer, and then it calls the consumer with
the persistent data container of the block entity
|
static <T> T |
modifyPersistentData(org.bukkit.block.BlockState blockState,
Function<ReadWriteNBT,T> function)
It takes a block state and a function that takes a ReadWriteNBT of the block
entities persistent data and returns a generic type T.
|
static void |
modifyPersistentData(org.bukkit.entity.Entity entity,
Consumer<ReadWriteNBT> consumer)
It allows you to modify the persistent data of an entity without any return
value
|
static <T> T |
modifyPersistentData(org.bukkit.entity.Entity entity,
Function<ReadWriteNBT,T> function)
It takes an entity and a function that takes a ReadWriteNBT from the entities
persistent data and returns a generic type T.
|
static ReadWriteNBT |
parseNBT(String nbtString)
It takes a nbt json string, and returns a ReadWriteNBT object
|
static boolean |
preloadApi()
Utility method for shaded versions to preload and check the API during
onEnable.
|
static ReadWriteNBT |
readFile(File file)
Reads NBT data from the provided file.
|
static <T extends NBTProxy> |
readNbt(org.bukkit.block.BlockState blockState,
Class<T> wrapper)
Create a read only proxy class for NBT, given an annotated interface.
|
static <T extends NBTProxy> |
readNbt(org.bukkit.entity.Entity entity,
Class<T> wrapper)
Create a read only proxy class for NBT, given an annotated interface.
|
static ReadWriteNBT |
readNBT(InputStream stream)
Reads in an NBT stream and returns a ReadWriteNBT object
|
static ReadableNBT |
readNbt(org.bukkit.inventory.ItemStack item)
Get a read only instance of the items NBT.
|
static <T extends NBTProxy> |
readNbt(org.bukkit.inventory.ItemStack item,
Class<T> wrapper)
Create a read only proxy class for NBT, given an annotated interface.
|
static ReadWriteNBT |
wrapNMSTag(Object nmsNbtTag)
Helper method for other developers using NMS.
|
static void |
writeFile(File file,
ReadWriteNBT nbt)
Saves NBT data to the provided file.
|
public static boolean preloadApi()
public static ReadableNBT readNbt(org.bukkit.inventory.ItemStack item)
item
- public static <T> T get(org.bukkit.inventory.ItemStack item, Function<ReadableItemNBT,T> getter)
item
- The itemstack you want to get the NBT fromgetter
- A function that takes a ReadableNBT and returns a value of type
T.public static void get(org.bukkit.inventory.ItemStack item, Consumer<ReadableItemNBT> getter)
item
- The itemstack you want to get the NBT frompublic static <T> T get(org.bukkit.entity.Entity entity, Function<ReadableNBT,T> getter)
entity
- The entity to get the NBT fromgetter
- A function that takes a ReadableNBT and returns a value.public static void get(org.bukkit.entity.Entity entity, Consumer<ReadableNBT> getter)
entity
- The entity to get the NBT frompublic static <T> T get(org.bukkit.block.BlockState blockState, Function<ReadableNBT,T> getter)
blockState
- The block state of the block you want to get the NBT from.getter
- A function that takes a ReadableNBT and returns a value of
type T.public static void get(org.bukkit.block.BlockState blockState, Consumer<ReadableNBT> getter)
blockState
- The block state of the block you want to get the NBT from.public static <T> T getPersistentData(org.bukkit.entity.Entity entity, Function<ReadableNBT,T> getter)
entity
- The entity to get the data fromgetter
- A function that takes a ReadableNBT and returns a value of type
T.public static <T> T getPersistentData(org.bukkit.block.BlockState blockState, Function<ReadableNBT,T> getter)
blockState
- The block state of the block you want to get the data from.getter
- A function that takes a ReadableNBT and returns a value of
type T.public static <T> T modify(org.bukkit.inventory.ItemStack item, Function<ReadWriteItemNBT,T> function)
item
- The item you want to modifyfunction
- The function that will be applied to the item.public static void modify(org.bukkit.inventory.ItemStack item, Consumer<ReadWriteItemNBT> consumer)
item
- The item you want to modifyconsumer
- The consumer that will be used to modify the NBT.public static <T> T modify(org.bukkit.entity.Entity entity, Function<ReadWriteNBT,T> function)
entity
- The entity to modifyfunction
- The function that will be called.public static void modifyComponents(org.bukkit.inventory.ItemStack item, Consumer<ReadWriteNBT> consumer)
item
- The item you want to modify the components ofconsumer
- The consumer that will be used to modify the components.public static <T> T modifyComponents(org.bukkit.inventory.ItemStack item, Function<ReadWriteNBT,T> function)
item
- The item you want to modify the components offunction
- The consumer that will be used to modify the components.public static void getComponents(org.bukkit.inventory.ItemStack item, Consumer<ReadableNBT> consumer)
item
- The item you want to read the components ofconsumer
- The consumer that will be used to read the components.public static <T> T getComponents(org.bukkit.inventory.ItemStack item, Function<ReadableNBT,T> function)
item
- The item you want to read the components offunction
- The consumer that will be used to read the components.public static void modify(org.bukkit.entity.Entity entity, Consumer<ReadWriteNBT> consumer)
entity
- The entity to modifyconsumer
- The consumer that will be called with the NBTEntity.public static <T> T modifyPersistentData(org.bukkit.entity.Entity entity, Function<ReadWriteNBT,T> function)
entity
- The entity to modify the data of.function
- The function that will be called.public static void modifyPersistentData(org.bukkit.entity.Entity entity, Consumer<ReadWriteNBT> consumer)
entity
- The entity to modifyconsumer
- The consumer that will be used to modify the persistent data.public static <T> T modify(org.bukkit.block.BlockState blockState, Function<ReadWriteNBT,T> function)
blockState
- The blockstate you want to modifyfunction
- The function that will be called.public static void modify(org.bukkit.block.BlockState blockState, Consumer<ReadWriteNBT> consumer)
blockState
- The blockstate you want to modifyconsumer
- A Consumer<ReadWriteNBT>. This is a function that
takes a ReadWriteNBT and does something with it.public static <T> T modifyPersistentData(org.bukkit.block.BlockState blockState, Function<ReadWriteNBT,T> function)
blockState
- The block state of the block you want to modify.function
- The function that will be called to modify the NBT data.public static void modifyPersistentData(org.bukkit.block.BlockState blockState, Consumer<ReadWriteNBT> consumer)
blockState
- The block state of the block you want to modify.consumer
- A Consumer<ReadWriteNBT>. This is a function that
takes a ReadWriteNBT and does something with it.public static ReadWriteNBT gameProfileToNBT(com.mojang.authlib.GameProfile profile)
profile
- The GameProfile to convert to NBTpublic static com.mojang.authlib.GameProfile gameProfileFromNBT(ReadableNBT compound)
compound
- The NBT tag to read the GameProfile from.public static ReadWriteNBT itemStackToNBT(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack you want to convert to NBT.@Nullable public static org.bukkit.inventory.ItemStack itemStackFromNBT(ReadableNBT compound)
compound
- The NBT tag to convert to an ItemStackpublic static ReadWriteNBT itemStackArrayToNBT(org.bukkit.inventory.ItemStack[] itemStacks)
itemStacks
- The ItemStack[] you want to convert to NBT@Nullable public static org.bukkit.inventory.ItemStack[] itemStackArrayFromNBT(ReadableNBT compound)
compound
- The NBT tag to convert to an ItemStack array.public static ReadWriteNBT createNBTObject()
public static ReadWriteNBT parseNBT(String nbtString)
nbtString
- The NBT string to parse.public static ReadWriteNBT readNBT(InputStream stream)
stream
- The NBT stream to read.public static ReadWriteNBT wrapNMSTag(Object nmsNbtTag)
nmsNbtTag
- Needs to be a valid net.minecraft.nbt.CompoundTagpublic static NBTFileHandle getFileHandle(File file) throws IOException
file
- IOException
public static ReadWriteNBT readFile(File file) throws IOException
Returns an empty tag if the file does not exist.
file
- file to readIOException
- exceptionpublic static void writeFile(File file, ReadWriteNBT nbt) throws IOException
Will fully override the file if it already exists.
file
- filenbt
- NBT dataIOException
- exceptionpublic static <T extends NBTProxy> T readNbt(org.bukkit.inventory.ItemStack item, Class<T> wrapper)
T
- item
- wrapper
- public static <T extends NBTProxy> T readNbt(org.bukkit.entity.Entity entity, Class<T> wrapper)
T
- entity
- wrapper
- public static <T extends NBTProxy> T readNbt(org.bukkit.block.BlockState blockState, Class<T> wrapper)
T
- blockState
- wrapper
- public static <T,X extends NBTProxy> T modify(org.bukkit.inventory.ItemStack item, Class<X> wrapper, Function<X,T> function)
item
- The item you want towrapper
- The target Proxy classfunction
- The function that will be applied to the item.public static <X extends NBTProxy> void modify(org.bukkit.inventory.ItemStack item, Class<X> wrapper, Consumer<X> consumer)
item
- The item you want to modifywrapper
- The target Proxy classconsumer
- The consumer that will be used to modify the NBT.public static <X extends NBTProxy> void modify(org.bukkit.entity.Entity entity, Class<X> wrapper, Consumer<X> consumer)
entity
- The entity to modifywrapper
- The target Proxy classconsumer
- The consumer that will be called with the proxy.public static <T,X extends NBTProxy> T modify(org.bukkit.entity.Entity entity, Class<X> wrapper, Function<X,T> function)
entity
- The entity to modifywrapper
- The target Proxy classfunction
- The Function that will be called with the proxy.public static <X extends NBTProxy> void modify(org.bukkit.block.BlockState blockState, Class<X> wrapper, Consumer<X> consumer)
blockState
- The blockstate you want to modifywrapper
- The target Proxy classconsumer
- The Consumer that will be called.public static <T,X extends NBTProxy> T modify(org.bukkit.block.BlockState blockState, Class<X> wrapper, Function<X,T> function)
blockState
- The blockstate you want to modifywrapper
- The target Proxy classfunction
- The function that will be called.Copyright © 2015–2024 tr7zw. All rights reserved.