public class NbtFactory
extends java.lang.Object
Constructor and Description |
---|
NbtFactory() |
Modifier and Type | Method and Description |
---|---|
static NbtCompound |
asCompound(NbtBase<?> tag)
Attempt to cast this NBT tag as a compund.
|
static NbtList<?> |
asList(NbtBase<?> tag)
Attempt to cast this NBT tag as a list.
|
static <T> NbtWrapper<T> |
fromBase(NbtBase<T> base)
Get a NBT wrapper from a NBT base.
|
static NbtWrapper<?> |
fromItemTag(ItemStack stack)
Construct a wrapper for an NBT tag stored (in memory) in an item stack.
|
static <T> NbtWrapper<T> |
fromNMS(java.lang.Object handle)
Initialize a NBT wrapper.
|
static NbtBase<java.lang.Byte> |
of(java.lang.String name,
byte value)
Constructs a NBT tag of type byte.
|
static NbtBase<byte[]> |
of(java.lang.String name,
byte[] value)
Constructs a NBT tag of type byte array.
|
static NbtBase<java.lang.Double> |
of(java.lang.String name,
double value)
Constructs a NBT tag of type double.
|
static NbtBase<java.lang.Float> |
of(java.lang.String name,
float value)
Constructs a NBT tag of type float.
|
static NbtBase<java.lang.Integer> |
of(java.lang.String name,
int value)
Constructs a NBT tag of type int.
|
static NbtBase<int[]> |
of(java.lang.String name,
int[] value)
Constructs a NBT tag of type int array.
|
static NbtBase<java.lang.Long> |
of(java.lang.String name,
long value)
Constructs a NBT tag of type long.
|
static NbtBase<java.lang.Short> |
of(java.lang.String name,
short value)
Constructs a NBT tag of type short.
|
static NbtBase<java.lang.String> |
of(java.lang.String name,
java.lang.String value)
Constructs a NBT tag of type string.
|
static NbtCompound |
ofCompound(java.lang.String name)
Construct a new NBT compound wrapper.
|
static NbtCompound |
ofCompound(java.lang.String name,
java.util.Collection<? extends NbtBase<?>> list)
Construct a new NBT compound initialized with a given list of NBT values.
|
static <T> NbtList<T> |
ofList(java.lang.String name,
java.util.Collection<? extends T> elements)
Construct a NBT list of out a list of values.
|
static <T> NbtList<T> |
ofList(java.lang.String name,
T... elements)
Construct a NBT list of out an array of values.
|
static <T> NbtWrapper<T> |
ofWrapper(java.lang.Class<?> type,
java.lang.String name,
T value)
Create a new NBT wrapper from a given type.
|
static <T> NbtWrapper<T> |
ofWrapper(NbtType type,
java.lang.String name)
Create a new NBT wrapper from a given type.
|
static <T> NbtWrapper<T> |
ofWrapper(NbtType type,
java.lang.String name,
T value)
Create a new NBT wrapper from a given type.
|
public static NbtCompound asCompound(NbtBase<?> tag)
tag
- - the NBT tag to cast.java.lang.UnsupportedOperationException
- If this is not a compound.public static NbtList<?> asList(NbtBase<?> tag)
tag
- - the NBT tag to cast.java.lang.UnsupportedOperationException
- If this is not a list.public static <T> NbtWrapper<T> fromBase(NbtBase<T> base)
This may clone the content if the NbtBase is not a NbtWrapper.
base
- - the base class.public static NbtWrapper<?> fromItemTag(ItemStack stack)
The item stack must be a wrapper for a CraftItemStack. Use
MinecraftReflection.getBukkitItemStack(ItemStack)
if not.
stack
- - the item stack.public static <T> NbtWrapper<T> fromNMS(java.lang.Object handle)
handle
- - the underlying net.minecraft.server object to wrap.public static NbtBase<java.lang.String> of(java.lang.String name, java.lang.String value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<java.lang.Byte> of(java.lang.String name, byte value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<java.lang.Short> of(java.lang.String name, short value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<java.lang.Integer> of(java.lang.String name, int value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<java.lang.Long> of(java.lang.String name, long value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<java.lang.Float> of(java.lang.String name, float value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<java.lang.Double> of(java.lang.String name, double value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<byte[]> of(java.lang.String name, byte[] value)
name
- - name of the tag.value
- - value of the tag.public static NbtBase<int[]> of(java.lang.String name, int[] value)
name
- - name of the tag.value
- - value of the tag.public static NbtCompound ofCompound(java.lang.String name, java.util.Collection<? extends NbtBase<?>> list)
name
- - the name of the compound wrapper.list
- - the list of elements to add.public static NbtCompound ofCompound(java.lang.String name)
name
- - the name of the compound wrapper.public static <T> NbtList<T> ofList(java.lang.String name, T... elements)
name
- - name of this list.elements
- - elements to add.public static <T> NbtList<T> ofList(java.lang.String name, java.util.Collection<? extends T> elements)
name
- - name of this list.elements
- - elements to add.public static <T> NbtWrapper<T> ofWrapper(NbtType type, java.lang.String name)
type
- - the NBT type.name
- - the name of the NBT tag.FieldAccessException
- If we're unable to create the underlying tag.public static <T> NbtWrapper<T> ofWrapper(NbtType type, java.lang.String name, T value)
type
- - the NBT type.name
- - the name of the NBT tag.value
- - the value of the new tag.FieldAccessException
- If we're unable to create the underlying tag.public static <T> NbtWrapper<T> ofWrapper(java.lang.Class<?> type, java.lang.String name, T value)
type
- - type of the NBT value.name
- - the name of the NBT tag.value
- - the value of the new tag.FieldAccessException
- If we're unable to create the underlying tag.java.lang.IllegalArgumentException
- If the given class type is not valid NBT.