public final class NbtSerialization extends Object
Modifier and Type | Method and Description |
---|---|
static org.bukkit.Location |
listTagsToLocation(org.bukkit.World world,
CompoundTag tag)
Read a Location from the "Pos" and "Rotation" children of a tag.
|
static org.bukkit.util.Vector |
listToVector(List<Double> list)
Create a Vector from a list of doubles.
|
static void |
locationToListTags(org.bukkit.Location loc,
CompoundTag tag)
Write a Location to the "Pos" and "Rotation" children of a tag.
|
static org.bukkit.inventory.ItemStack[] |
readInventory(List<CompoundTag> tagList,
int start,
int size)
Read a full inventory (players, chests, etc.) from a compound list.
|
static org.bukkit.inventory.ItemStack |
readItem(CompoundTag tag)
Read an item stack in from an NBT tag.
|
static org.bukkit.World |
readWorld(GlowServer server,
CompoundTag compound)
Attempt to resolve a world based on the contents of a compound tag.
|
static List<Double> |
vectorToList(org.bukkit.util.Vector vec)
Create a list of doubles from a Vector.
|
static List<CompoundTag> |
writeInventory(org.bukkit.inventory.ItemStack[] items,
int start)
Write a full inventory (players, chests, etc.) to a compound list.
|
static CompoundTag |
writeItem(org.bukkit.inventory.ItemStack stack,
int slot)
Write an item stack to an NBT tag.
|
static void |
writeWorld(org.bukkit.World world,
CompoundTag compound)
Save world identifiers (UUID and dimension) to a compound tag for later lookup.
|
public static org.bukkit.inventory.ItemStack readItem(CompoundTag tag)
Returns null if no item exists.
tag
- The tag to read from.public static CompoundTag writeItem(org.bukkit.inventory.ItemStack stack, int slot)
Null stacks produce an empty tag, and if slot is negative it is omitted from the result.
stack
- The stack to write, or null.slot
- The slot, or negative to omit.public static org.bukkit.inventory.ItemStack[] readInventory(List<CompoundTag> tagList, int start, int size)
tagList
- The list of CompoundTags to read from.start
- The slot number to consider the inventory's start.size
- The desired size of the inventory.public static List<CompoundTag> writeInventory(org.bukkit.inventory.ItemStack[] items, int start)
items
- An array with the contents of the inventory.start
- The slot number to consider the inventory's start.public static org.bukkit.World readWorld(GlowServer server, CompoundTag compound)
server
- The server to look up worlds in.compound
- The tag to read the world from.public static void writeWorld(org.bukkit.World world, CompoundTag compound)
world
- The world to identify.compound
- The tag to write to.public static org.bukkit.Location listTagsToLocation(org.bukkit.World world, CompoundTag tag)
If "Pos" is absent or invalid, null is returned.
If "Rotation" is absent or invalid, it is skipped and a location without rotation is returned.
world
- The world of the location (see readWorld).tag
- The tag to read from.public static void locationToListTags(org.bukkit.Location loc, CompoundTag tag)
Does not save world information, use writeWorld instead.
loc
- The location to write.tag
- The tag to write to.public static org.bukkit.util.Vector listToVector(List<Double> list)
If the list is invalid, a zero vector is returned.
list
- The list to read from.Copyright © 2021. All rights reserved.