Class LegacyNbt
java.lang.Object
dev.triumphteam.gui.components.nbt.LegacyNbt
- All Implemented Interfaces:
NbtWrapper
public final class LegacyNbt extends java.lang.Object implements NbtWrapper
Class to set / get NBT tags from items.
I hate this class.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
NMS_VERSION
static java.lang.String
PACKAGE_NAME
-
Constructor Summary
Constructors Constructor Description LegacyNbt()
-
Method Summary
Modifier and Type Method Description static org.bukkit.inventory.ItemStack
asBukkitCopy(java.lang.Object nmsItemStack)
Mimics the CraftItemStack#asBukkitCopy method.static java.lang.Object
asNMSCopy(org.bukkit.inventory.ItemStack itemStack)
Mimics the CraftItemStack#asNMSCopy method.@Nullable java.lang.String
getString(@NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key)
Gets the NBT tag based on a given key.static java.lang.Object
getTag(java.lang.Object nmsItemStack)
Mimics the nmsItemStack#getTag method.org.bukkit.inventory.ItemStack
removeTag(@NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key)
Removes a tag from anItemStack
.org.bukkit.inventory.ItemStack
setBoolean(@NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key, boolean value)
Sets a boolean to theItemStack
.org.bukkit.inventory.ItemStack
setString(@NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key, java.lang.String value)
Sets an NBT tag to the anItemStack
.
-
Field Details
-
PACKAGE_NAME
public static final java.lang.String PACKAGE_NAME -
NMS_VERSION
public static final java.lang.String NMS_VERSION
-
-
Constructor Details
-
LegacyNbt
public LegacyNbt()
-
-
Method Details
-
setString
public org.bukkit.inventory.ItemStack setString(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key, java.lang.String value)Sets an NBT tag to the anItemStack
.- Specified by:
setString
in interfaceNbtWrapper
- Parameters:
itemStack
- The currentItemStack
to be set.key
- The NBT key to use.value
- The tag value to set.- Returns:
- An
ItemStack
that has NBT set.
-
removeTag
public org.bukkit.inventory.ItemStack removeTag(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key)Removes a tag from anItemStack
.- Specified by:
removeTag
in interfaceNbtWrapper
- Parameters:
itemStack
- The currentItemStack
to be remove.key
- The NBT key to remove.- Returns:
- An
ItemStack
that has the tag removed.
-
setBoolean
public org.bukkit.inventory.ItemStack setBoolean(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key, boolean value)Sets a boolean to theItemStack
. Mainly used for setting an item to be unbreakable on older versions.- Specified by:
setBoolean
in interfaceNbtWrapper
- Parameters:
itemStack
- TheItemStack
to set the boolean to.key
- The key to use.value
- The boolean value.- Returns:
- An
ItemStack
with a boolean value set.
-
getString
@Nullable public @Nullable java.lang.String getString(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, java.lang.String key)Gets the NBT tag based on a given key.- Specified by:
getString
in interfaceNbtWrapper
- Parameters:
itemStack
- TheItemStack
to get from.key
- The key to look for.- Returns:
- The tag that was stored in the
ItemStack
.
-
getTag
public static java.lang.Object getTag(java.lang.Object nmsItemStack)Mimics the nmsItemStack#getTag method.- Parameters:
nmsItemStack
- The NMS ItemStack to get from.- Returns:
- The tag compound.
-
asNMSCopy
public static java.lang.Object asNMSCopy(org.bukkit.inventory.ItemStack itemStack)Mimics the CraftItemStack#asNMSCopy method.- Parameters:
itemStack
- The ItemStack to make NMS copy.- Returns:
- An NMS copy of the ItemStack.
-
asBukkitCopy
public static org.bukkit.inventory.ItemStack asBukkitCopy(java.lang.Object nmsItemStack)Mimics the CraftItemStack#asBukkitCopy method.- Parameters:
nmsItemStack
- The NMS ItemStack to turn intoItemStack
.- Returns:
- The new
ItemStack
.
-