Class BaseItemBuilder<B extends BaseItemBuilder<B>>

java.lang.Object
dev.triumphteam.gui.builder.item.BaseItemBuilder<B>
Type Parameters:
B - The ItemBuilder type so the methods can cast to the subtype
Direct Known Subclasses:
ItemBuilder, SkullBuilder

public abstract class BaseItemBuilder<B extends BaseItemBuilder<B>>
extends java.lang.Object
Contains all the common methods for the future ItemBuilders
  • Method Summary

    Modifier and Type Method Description
    B amount​(int amount)
    Sets the amount of items
    GuiItem asGuiItem()
    Creates a GuiItem instead of an ItemStack
    GuiItem asGuiItem​(@NotNull GuiAction<org.bukkit.event.inventory.InventoryClickEvent> action)
    Creates a GuiItem instead of an ItemStack
    org.bukkit.inventory.ItemStack build()
    Builds the item into ItemStack
    B disenchant​(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Disenchants a certain Enchantment from the ItemStack
    B enchant​(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Enchants the ItemStack
    B enchant​(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
    Enchants the ItemStack
    B enchant​(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction)
    Enchants the ItemStack
    B flags​(@NotNull org.bukkit.inventory.ItemFlag... flags)
    Add an ItemFlag to the item
    B glow()
    Makes the ItemStack glow
    B glow​(boolean glow)
    Adds or removes the ItemStack glow
    B lore​(@NotNull java.util.function.Consumer<java.util.List<net.kyori.adventure.text.Component>> lore)
    Consumer for freely adding to the lore
    B lore​(@NotNull java.util.List<net.kyori.adventure.text.Component> lore)
    Set the lore lines of an item
    B lore​(@NotNull net.kyori.adventure.text.Component... lore)
    Set the lore lines of an item
    B model​(int modelData)
    Sets the custom model data of the item Added in 1.13
    B name​(@NotNull net.kyori.adventure.text.Component name)
    Sets the display name of the item using Component
    B pdc​(@NotNull java.util.function.Consumer<org.bukkit.persistence.PersistentDataContainer> consumer)
    Consumer for applying PersistentDataContainer to the item This method will only work on versions above 1.14
    B removeNbt​(@NotNull java.lang.String key)
    Removes NBT tag from the ItemStack
    B setNbt​(@NotNull java.lang.String key, boolean value)
    Sets NBT tag to the ItemStack
    B setNbt​(@NotNull java.lang.String key, @Nullable java.lang.String value)
    Sets NBT tag to the ItemStack
    B unbreakable()
    Makes the ItemStack unbreakable
    B unbreakable​(boolean unbreakable)
    Sets the item as unbreakable

    Methods inherited from class java.lang.Object

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

    • name

      @Contract("_ -> this") public B name​(@NotNull @NotNull net.kyori.adventure.text.Component name)
      Sets the display name of the item using Component
      Parameters:
      name - The Component name
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • amount

      public B amount​(int amount)
      Sets the amount of items
      Parameters:
      amount - the amount of items
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • lore

      @Contract("_ -> this") public B lore​(@NotNull @NotNull net.kyori.adventure.text.Component... lore)
      Set the lore lines of an item
      Parameters:
      lore - Lore lines as varargs
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • lore

      @Contract("_ -> this") public B lore​(@NotNull @NotNull java.util.List<net.kyori.adventure.text.Component> lore)
      Set the lore lines of an item
      Parameters:
      lore - A List with the lore lines
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • lore

      @Contract("_ -> this") public B lore​(@NotNull @NotNull java.util.function.Consumer<java.util.List<net.kyori.adventure.text.Component>> lore)
      Consumer for freely adding to the lore
      Parameters:
      lore - A Consumer with the List of lore Component
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • enchant

      @Contract("_, _, _ -> this") public B enchant​(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction)
      Enchants the ItemStack
      Parameters:
      enchantment - The Enchantment to add
      level - The level of the Enchantment
      ignoreLevelRestriction - If should or not ignore it
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • enchant

      @Contract("_, _ -> this") public B enchant​(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
      Enchants the ItemStack
      Parameters:
      enchantment - The Enchantment to add
      level - The level of the Enchantment
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • enchant

      @Contract("_ -> this") public B enchant​(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Enchants the ItemStack
      Parameters:
      enchantment - The Enchantment to add
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • disenchant

      @Contract("_ -> this") public B disenchant​(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Disenchants a certain Enchantment from the ItemStack
      Parameters:
      enchantment - The Enchantment to remove
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • flags

      @Contract("_ -> this") public B flags​(@NotNull @NotNull org.bukkit.inventory.ItemFlag... flags)
      Add an ItemFlag to the item
      Parameters:
      flags - The ItemFlag to add
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • unbreakable

      @Contract(" -> this") public B unbreakable()
      Makes the ItemStack unbreakable
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • unbreakable

      @Contract("_ -> this") public B unbreakable​(boolean unbreakable)
      Sets the item as unbreakable
      Parameters:
      unbreakable - If should or not be unbreakable
      Returns:
      ItemBuilder
    • glow

      @Contract(" -> this") public B glow()
      Makes the ItemStack glow
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • glow

      @Contract("_ -> this") public B glow​(boolean glow)
      Adds or removes the ItemStack glow
      Parameters:
      glow - Should the item glow
      Returns:
      ItemBuilder
    • pdc

      @Contract("_ -> this") public B pdc​(@NotNull @NotNull java.util.function.Consumer<org.bukkit.persistence.PersistentDataContainer> consumer)
      Consumer for applying PersistentDataContainer to the item This method will only work on versions above 1.14
      Parameters:
      consumer - The Consumer with the PDC
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • model

      @Contract("_ -> this") public B model​(int modelData)
      Sets the custom model data of the item Added in 1.13
      Parameters:
      modelData - The custom model data from the resource pack
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • setNbt

      @Contract("_, _ -> this") public B setNbt​(@NotNull @NotNull java.lang.String key, @Nullable @Nullable java.lang.String value)
      Sets NBT tag to the ItemStack
      Parameters:
      key - The NBT key
      value - The NBT value
      Returns:
      ItemBuilder
    • setNbt

      @Contract("_, _ -> this") public B setNbt​(@NotNull @NotNull java.lang.String key, boolean value)
      Sets NBT tag to the ItemStack
      Parameters:
      key - The NBT key
      value - The NBT value
      Returns:
      ItemBuilder
    • removeNbt

      @Contract("_ -> this") public B removeNbt​(@NotNull @NotNull java.lang.String key)
      Removes NBT tag from the ItemStack
      Parameters:
      key - The NBT key
      Returns:
      ItemBuilder
    • build

      public org.bukkit.inventory.ItemStack build()
      Builds the item into ItemStack
      Returns:
      The fully built ItemStack
    • asGuiItem

      @Contract(" -> new") public GuiItem asGuiItem()
      Creates a GuiItem instead of an ItemStack
      Returns:
      A GuiItem with no GuiAction
    • asGuiItem

      @Contract("_ -> new") public GuiItem asGuiItem​(@NotNull @NotNull GuiAction<org.bukkit.event.inventory.InventoryClickEvent> action)
      Creates a GuiItem instead of an ItemStack
      Parameters:
      action - The GuiAction to apply to the item
      Returns:
      A GuiItem with GuiAction