Class ItemWrapper

java.lang.Object
com.burchard36.api.utils.ItemWrapper
Direct Known Subclasses:
ClickableItem

public class ItemWrapper extends Object
A basic class to wrap around ItemStack
  • Constructor Details

    • ItemWrapper

      public ItemWrapper(org.bukkit.inventory.ItemStack stack)
      Specifies directly what ItemStack you want to wrap around
      Parameters:
      stack - A ItemStack
    • ItemWrapper

      public ItemWrapper(@Nonnull org.bukkit.Material material)
      Creates a ItemStack with a Integer of 1 as the amount
      Parameters:
      material - A Material enum
    • ItemWrapper

      public ItemWrapper(@Nonnull org.bukkit.Material material, int amount)
      Creates a ItemStack with a specific Material and Integer amount
      Parameters:
      material - A Material to use
      amount - A Integer amount
  • Method Details

    • getDisplayName

      public final String getDisplayName()
      Might be null
      Returns:
      String of display name, or null
    • getLore

      public final List<String> getLore()
      Might be null
      Returns:
      List of Strings for the lore, or null
    • setDisplayName

      public final ItemWrapper setDisplayName(String displayName)
      Sets the display name of the wrapped ItemStack
      Parameters:
      displayName - A String to set the ItemStack's name to, color codes automatically handled
      Returns:
      Instance of this ItemWrapper
    • addItemLore

      public final ItemWrapper addItemLore(String... lore)
      Adds a Lore line to the linked ItemStack
      Parameters:
      lore - a list of String's, color codes automatically handled
      Returns:
      instance of this ItemWrapper
    • setItemLore

      public final ItemWrapper setItemLore(List<String> itemLore)
      Sets the items Lore directly
      Parameters:
      itemLore - A List of String's
      Returns:
      instance of this ItemWrapper
    • setModelData

      public final ItemWrapper setModelData(int data)
      Sets the CustomModelData Integer of the ItemStack
      Parameters:
      data - A Integer to set
      Returns:
      instance of this ItemWrapper
    • addEnchantment

      public final ItemWrapper addEnchantment(org.bukkit.enchantments.Enchantment enchantment, int level)
      Adds a specific Enchantment with a specified Integer level
      Parameters:
      enchantment - An Enchantment to apply
      level - A Integer level to set
      Returns:
      instance of this ItemWrapper
    • addEnchantments

      public final ItemWrapper addEnchantments(HashMap<org.bukkit.enchantments.Enchantment,​Integer> enchantments)
      Adds a Map of Enchantment and Integer to the linked ItemStack's Enchantment list
      Parameters:
      enchantments - a Map or Enchantment enums and Integer as level-values
      Returns:
      instance of this ItemWrapper
    • setSkullTo

      public final ItemWrapper setSkullTo(UUID playerUuid)
      If the linked ItemStack is a PLAYER_HEAD, it will set a owning player's UUID
      Parameters:
      playerUuid - The player's UUID
      Returns:
      instance of this ItemWrapper
    • addDataString

      public final ItemWrapper addDataString(String key, String value)
      Adds a String value to the linked ItemStack's PersistentDataContainer
      Parameters:
      key - A String value for the key to be set as
      value - A String value for the value to be set as
      Returns:
      instance of this ItemWrapper
    • addDataInteger

      public final ItemWrapper addDataInteger(String key, int value)
      Adds a Integer value to the linked ItemStack's PersistentDataContainer
      Parameters:
      key - A String value for the key to be set as
      value - A Integer value for the value to be set as
      Returns:
      instance of this ItemWrapper
    • getStringDataValue

      public final String getStringDataValue(String key)
      Gets a String value form the linked ItemStack's PersistentDataContainer
      Parameters:
      key - A String key to search under
      Returns:
      A String if a value was found, null if not
    • getIntegerDataValue

      public final Integer getIntegerDataValue(String key)
      Gets a Integer value form the linked ItemStack's PersistentDataContainer
      Parameters:
      key - A String key to search under
      Returns:
      A Integer if a value was found, null if not
    • hasDataString

      public final boolean hasDataString(String key)
      Checks if the linked ItemStack's PersistentDataContainer has a String value
      Parameters:
      key - A String key to search under
      Returns:
      A Boolean, true if value was found
    • hasDataInteger

      public final boolean hasDataInteger(String key)
      Checks if the linked ItemStack's PersistentDataContainer has a Integer value
      Parameters:
      key - A String key to search under
      Returns:
      A Boolean, true if value was found
    • getItemStack

      public final org.bukkit.inventory.ItemStack getItemStack()
      Returns the ItemStack from constructor
      Returns:
      ItemStack, may be modified!