Class ItemBuilder

java.lang.Object
tech.guilhermekaua.spigotboot.core.utils.ItemBuilder

public class ItemBuilder extends Object
A utility class that helps to create and modify ItemStacks.
  • Constructor Details

    • ItemBuilder

      public ItemBuilder(org.bukkit.inventory.ItemStack item)
      Creates a new ItemBuilder with the given ItemStack.
      Parameters:
      item - the ItemStack to use
    • ItemBuilder

      public ItemBuilder(org.bukkit.Material type)
      Creates a new ItemBuilder with the given Material type.
      Parameters:
      type - the Material type to use
    • ItemBuilder

      public ItemBuilder(org.bukkit.Material type, int data)
      Creates a new ItemBuilder with the given Material type and data value.
      Parameters:
      type - the Material type to use
      data - the data value to use
    • ItemBuilder

      public ItemBuilder(String url)
      Creates a new ItemBuilder with a skull item from the given URL.
      Parameters:
      url - the URL to get the skull item from
    • ItemBuilder

      public ItemBuilder(org.bukkit.Material type, org.bukkit.Color color)
      Creates a new ItemBuilder with a leather armor item of the given color.
      Parameters:
      type - the Material type to use
      color - the Color to use
  • Method Details

    • setItem

      public ItemBuilder setItem(org.bukkit.inventory.ItemStack item)
    • setGlow

      public ItemBuilder setGlow(boolean glow)
    • changeItemMeta

      public ItemBuilder changeItemMeta(Consumer<org.bukkit.inventory.meta.ItemMeta> consumer)
      Changes the ItemMeta of the ItemStack using the given Consumer function.
      Parameters:
      consumer - the Consumer function to apply to the ItemMeta
      Returns:
      this ItemBuilder instance for chaining
    • setName

      public ItemBuilder setName(String name)
      Sets the display name of the ItemStack.
      Parameters:
      name - the display name to use
      Returns:
      this ItemBuilder instance for chaining
    • addLore

      public ItemBuilder addLore(String... lore)
      Adds some strings to the lore of the ItemStack.
      Parameters:
      lore - an array of strings to add to the lore
      Returns:
      this ItemBuilder instance for chaining
    • addLore

      public ItemBuilder addLore(int index, String lore)
      Adds a string to the lore of the ItemStack at the given index.
      Parameters:
      index - the index to insert the string at
      lore - the string to add to the lore
      Returns:
      this ItemBuilder instance for chaining
    • setLore

      public ItemBuilder setLore(int index, String lore)
      Replaces a string in the lore of the ItemStack at the given index.
      Parameters:
      index - the index to replace the string at
      lore - the string to replace in the lore
      Returns:
      this ItemBuilder instance for chaining
    • deleteLoreLine

      public ItemBuilder deleteLoreLine(int index)
      Deletes a string from the lore of the ItemStack at the given index.
      Parameters:
      index - the index to delete the string from
      Returns:
      this ItemBuilder instance for chaining
    • findLore

      public int findLore(String lore)
      Finds the index of a string in the lore of the ItemStack that contains the given substring.
      Parameters:
      lore - the substring to look for in the lore
      Returns:
      the index of the string that contains the substring, or -1 if not found
    • getLore

      public List<String> getLore()
      Returns the lore of the ItemStack as a list of strings.
      Returns:
      the lore of the ItemStack, or null if none
    • setLore

      public ItemBuilder setLore(String... lore)
      Sets the lore of the ItemStack.
      Parameters:
      lore - an array of strings to use as the lore
      Returns:
      this ItemBuilder instance for chaining
    • setLore

      public ItemBuilder setLore(List<String> lore)
      Sets the lore of the ItemStack.
      Parameters:
      lore - a list of strings to use as the lore
      Returns:
      this ItemBuilder instance for chaining
    • placeholder

      public ItemBuilder placeholder(String placeholder, String value)
      Replaces a placeholder in the lore of the ItemStack with a given value.
      Parameters:
      placeholder - the placeholder to replace
      value - the value to replace with
      Returns:
      this ItemBuilder instance for chaining
    • wrap

      public org.bukkit.inventory.ItemStack wrap()
      Returns the ItemStack that this builder is working on.
      Returns:
      the ItemStack instance