Class ItemNbt

java.lang.Object
dev.triumphteam.gui.components.util.ItemNbt

public final class ItemNbt
extends java.lang.Object
Ideally this wouldn't need to be an util, but because of the LegacyNbt it makes it easier. Legacy.. Will use the PDC wrapper if version is higher than 1.14
  • Constructor Summary

    Constructors 
    Constructor Description
    ItemNbt()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String getString​(@NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull java.lang.String key)
    Gets the NBT tag based on a given key.
    static org.bukkit.inventory.ItemStack removeTag​(@NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull java.lang.String key)
    Removes a tag from an ItemStack.
    static org.bukkit.inventory.ItemStack setBoolean​(@NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull java.lang.String key, boolean value)
    Sets a boolean to the ItemStack.
    static org.bukkit.inventory.ItemStack setString​(@NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull java.lang.String key, @NotNull java.lang.String value)
    Sets an NBT tag to the an ItemStack.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • setString

      public static org.bukkit.inventory.ItemStack setString​(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)
      Sets an NBT tag to the an ItemStack.
      Parameters:
      itemStack - The current ItemStack to be set.
      key - The NBT key to use.
      value - The tag value to set.
      Returns:
      An ItemStack that has NBT set.
    • getString

      public static java.lang.String getString​(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull @NotNull java.lang.String key)
      Gets the NBT tag based on a given key.
      Parameters:
      itemStack - The ItemStack to get from.
      key - The key to look for.
      Returns:
      The tag that was stored in the ItemStack.
    • setBoolean

      public static org.bukkit.inventory.ItemStack setBoolean​(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull @NotNull java.lang.String key, boolean value)
      Sets a boolean to the ItemStack. Mainly used for setting an item to be unbreakable on older versions.
      Parameters:
      itemStack - The ItemStack to set the boolean to.
      key - The key to use.
      value - The boolean value.
      Returns:
      An ItemStack with a boolean value set.
    • removeTag

      public static org.bukkit.inventory.ItemStack removeTag​(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @NotNull @NotNull java.lang.String key)
      Removes a tag from an ItemStack.
      Parameters:
      itemStack - The current ItemStack to be remove.
      key - The NBT key to remove.
      Returns:
      An ItemStack that has the tag removed.