public final class NbtFactory
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
class |
NbtFactory.NbtCompound
Represents a root NBT compound.
|
class |
NbtFactory.NbtList
Represents a root NBT list.
|
static class |
NbtFactory.StreamOptions
Whether or not to enable stream compression.
|
static interface |
NbtFactory.Wrapper
Represents an object that provides a view of a native NMS class.
|
| Modifier and Type | Method and Description |
|---|---|
static NbtFactory.NbtCompound |
createCompound()
Construct a new NBT compound.
|
static NbtFactory.NbtList |
createList(java.lang.Iterable<? extends java.lang.Object> iterable)
Construct a new NBT list of an unspecified type.
|
static NbtFactory.NbtList |
createList(java.lang.Object... content)
Construct a new NBT list of an unspecified type.
|
static NbtFactory.NbtCompound |
createRootCompound(java.lang.String name)
Construct a new NBT root compound.
|
static NbtFactory.NbtCompound |
fromCompound(java.lang.Object nmsCompound)
Construct a new NBT wrapper from a compound.
|
static NbtFactory.NbtCompound |
fromItemTag(org.bukkit.inventory.ItemStack stack)
Construct a wrapper for an NBT tag stored (in memory) in an item stack.
|
static NbtFactory.NbtList |
fromList(java.lang.Object nmsList)
Construct a new NBT wrapper from a list.
|
static NbtFactory.NbtCompound |
fromStream(com.google.common.io.InputSupplier<? extends java.io.InputStream> stream,
NbtFactory.StreamOptions option)
Load the content of a file from a stream.
|
static org.bukkit.inventory.ItemStack |
getCraftItemStack(org.bukkit.inventory.ItemStack stack)
Retrieve a CraftItemStack version of the stack.
|
static void |
saveStream(NbtFactory.NbtCompound source,
com.google.common.io.OutputSupplier<? extends java.io.OutputStream> stream,
NbtFactory.StreamOptions option)
Save the content of a NBT compound to a stream.
|
static void |
setItemTag(org.bukkit.inventory.ItemStack stack,
NbtFactory.NbtCompound compound)
Set the NBT compound tag of a given item stack.
|
public static NbtFactory.NbtList createList(java.lang.Object... content)
public static NbtFactory.NbtList createList(java.lang.Iterable<? extends java.lang.Object> iterable)
public static NbtFactory.NbtCompound createCompound()
Use NbtFactory.ConvertedMap.getHandle() to modify it.
public static NbtFactory.NbtCompound createRootCompound(java.lang.String name)
This compound must be given a name, as it is the root object.
name - - the name of the compound.public static NbtFactory.NbtList fromList(java.lang.Object nmsList)
nmsList - - the NBT list.public static NbtFactory.NbtCompound fromStream(com.google.common.io.InputSupplier<? extends java.io.InputStream> stream, NbtFactory.StreamOptions option) throws java.io.IOException
Use Files.newInputStreamSupplier(java.io.File) to provide a
stream from a file.
stream - - the stream supplier.option - - whether or not to decompress the input stream.java.io.IOException - If anything went wrong.public static void saveStream(NbtFactory.NbtCompound source, com.google.common.io.OutputSupplier<? extends java.io.OutputStream> stream, NbtFactory.StreamOptions option) throws java.io.IOException
Use Files.newOutputStreamSupplier(java.io.File) to provide a
stream supplier to a file.
source - - the NBT compound to save.stream - - the stream.option - - whether or not to compress the output.java.io.IOException - If anything went wrong.public static NbtFactory.NbtCompound fromCompound(java.lang.Object nmsCompound)
nmsCompound - - the NBT compund.public static void setItemTag(org.bukkit.inventory.ItemStack stack,
NbtFactory.NbtCompound compound)
The item stack must be a wrapper for a CraftItemStack. Use
MinecraftReflection.getBukkitItemStack(ItemStack) if not.
stack - - the item stack, cannot be air.compound - - the new NBT compound, or NULL to remove it.java.lang.IllegalArgumentException - If the stack is not a CraftItemStack, or it represents air.public static NbtFactory.NbtCompound fromItemTag(org.bukkit.inventory.ItemStack stack)
The item stack must be a wrapper for a CraftItemStack.
stack - - the item stack.public static org.bukkit.inventory.ItemStack getCraftItemStack(org.bukkit.inventory.ItemStack stack)
stack - - the stack to convert.