Class LegacyNBT
java.lang.Object
io.rhythmknights.coreapi.component.module.nbt.LegacyNBT
- All Implemented Interfaces:
NBTWrapper
Class to set / get NBT tags from items.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.inventory.ItemStackasBukkitCopy(Object nmsItemStack) Mimics the CraftItemStack#asBukkitCopy method.static ObjectasNMSCopy(org.bukkit.inventory.ItemStack itemStack) Mimics the CraftItemStack#asNMSCopy method.@Nullable StringGets the NBT tag based on a given key.static ObjectMimics the nmsItemStack#getTag method.org.bukkit.inventory.ItemStackRemoves a tag from anItemStack.org.bukkit.inventory.ItemStacksetBoolean(@NotNull org.bukkit.inventory.ItemStack itemStack, String key, boolean value) Sets a boolean to theItemStack.org.bukkit.inventory.ItemStackSets an NBT tag to the anItemStack.
-
Field Details
-
PACKAGE_NAME
-
NMS_VERSION
-
-
Constructor Details
-
LegacyNBT
public LegacyNBT()
-
-
Method Details
-
setString
public org.bukkit.inventory.ItemStack setString(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, String key, String value) Sets an NBT tag to the anItemStack.- Specified by:
setStringin interfaceNBTWrapper- Parameters:
itemStack- The currentItemStackto be set.key- The NBT key to use.value- The tag value to set.- Returns:
- An
ItemStackthat has NBT set.
-
removeTag
public org.bukkit.inventory.ItemStack removeTag(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, String key) Removes a tag from anItemStack.- Specified by:
removeTagin interfaceNBTWrapper- Parameters:
itemStack- The currentItemStackto be remove.key- The NBT key to remove.- Returns:
- An
ItemStackthat has the tag removed.
-
setBoolean
public org.bukkit.inventory.ItemStack setBoolean(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, String key, boolean value) Sets a boolean to theItemStack. Mainly used for setting an item to be unbreakable on older versions.- Specified by:
setBooleanin interfaceNBTWrapper- Parameters:
itemStack- TheItemStackto set the boolean to.key- The key to use.value- The boolean value.- Returns:
- An
ItemStackwith a boolean value set.
-
getString
@Nullable public @Nullable String getString(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, String key) Gets the NBT tag based on a given key.- Specified by:
getStringin interfaceNBTWrapper- Parameters:
itemStack- TheItemStackto get from.key- The key to look for.- Returns:
- The tag that was stored in the
ItemStack.
-
getTag
Mimics the nmsItemStack#getTag method.- Parameters:
nmsItemStack- The NMS ItemStack to get from.- Returns:
- The tag compound.
-
asNMSCopy
Mimics the CraftItemStack#asNMSCopy method.- Parameters:
itemStack- The ItemStack to make NMS copy.- Returns:
- An NMS copy of the ItemStack.
-
asBukkitCopy
Mimics the CraftItemStack#asBukkitCopy method.- Parameters:
nmsItemStack- The NMS ItemStack to turn intoItemStack.- Returns:
- The new
ItemStack.
-