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:
BannerBuilder, BookBuilder, FireworkBuilder, ItemBuilder, MapBuilder, SkullBuilder

public abstract class BaseItemBuilder<B extends BaseItemBuilder<B>> extends Object
Contains all the common methods for the future ItemBuilders
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BaseItemBuilder(@NotNull org.bukkit.inventory.ItemStack itemStack)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Deprecated.
    In favor of enchant(Enchantment), nothing changed just the name, will be removed in 3.0.1
    addEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
    Deprecated.
    In favor of enchant(Enchantment, int), nothing changed just the name, will be removed in 3.0.1
    addEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction)
    Deprecated.
    In favor of enchant(Enchantment, int, boolean), nothing changed just the name, will be removed in 3.0.1
    addItemFlags(@NotNull org.bukkit.inventory.ItemFlag... flags)
    Deprecated.
    In favor of flags(ItemFlag...), nothing changed just the name, will be removed in 3.0.1
    addLore(@NotNull String... lore)
    Deprecated.
    In favor of lore(Consumer), will be removed in 3.0.1
    addLore(@NotNull List<String> lore)
    Deprecated.
    In favor of lore(Consumer), will be removed in 3.0.1
    amount(int amount)
    Sets the amount of items
    @NotNull GuiItem
    Creates a GuiItem instead of an ItemStack
    @NotNull GuiItem
    asGuiItem(@NotNull GuiAction<org.bukkit.event.inventory.InventoryClickEvent> action)
    Creates a GuiItem instead of an ItemStack
    @NotNull org.bukkit.inventory.ItemStack
    Builds the item into ItemStack
    color(@NotNull org.bukkit.Color color)
    Color an ItemStack
    disenchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Disenchants a certain Enchantment from the ItemStack
    enchant(@NotNull Map<org.bukkit.enchantments.Enchantment,Integer> enchantments)
    Enchants the ItemStack with the specified map where the value is the level of the key's enchantment
    enchant(@NotNull Map<org.bukkit.enchantments.Enchantment,Integer> enchantments, boolean ignoreLevelRestriction)
    Enchants the ItemStack with the specified map where the value is the level of the key's enchantment
    enchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Enchants the ItemStack
    enchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
    Enchants the ItemStack
    enchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction)
    Enchants the ItemStack
    flags(@NotNull org.bukkit.inventory.ItemFlag... flags)
    Add an ItemFlag to the item
    protected @NotNull org.bukkit.inventory.ItemStack
    Package private getter for extended builders
    protected @NotNull org.bukkit.inventory.meta.ItemMeta
    Package private getter for extended builders
    Makes the ItemStack glow
    glow(boolean glow)
    Adds or removes the ItemStack glow
    lore(@NotNull Consumer<List<@Nullable net.kyori.adventure.text.Component>> lore)
    Consumer for freely adding to the lore
    lore(@NotNull List<@Nullable net.kyori.adventure.text.Component> lore)
    Set the lore lines of an item
    lore(@Nullable net.kyori.adventure.text.Component @NotNull ... lore)
    Set the lore lines of an item
    model(int modelData)
    Sets the custom model data of the item Added in 1.13
    name(@NotNull net.kyori.adventure.text.Component name)
    Sets the display name of the item using Component
    pdc(@NotNull Consumer<org.bukkit.persistence.PersistentDataContainer> consumer)
    Consumer for applying PersistentDataContainer to the item This method will only work on versions above 1.14
    removeEnchantment(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Deprecated.
    In favor of disenchant(Enchantment), nothing changed just the name, will be removed in 3.0.1
    removeNbt(@NotNull String key)
    Removes NBT tag from the ItemStack
    setAmount(int amount)
    Deprecated.
    In favor of amount(int), nothing changed just the name, will be removed in 3.0.1
    protected void
    setItemStack(@NotNull org.bukkit.inventory.ItemStack itemStack)
    Package private setter for the extended builders
    setLore(@NotNull String... lore)
    Deprecated.
    In favor of lore(Component...), will be removed in 3.0.1
    setLore(@NotNull List<String> lore)
    Deprecated.
    In favor of lore(List), will be removed in 3.0.1
    protected void
    setMeta(@NotNull org.bukkit.inventory.meta.ItemMeta meta)
    Package private setter for the extended builders
    setName(@NotNull String name)
    Deprecated.
    In favor of name(Component), will be removed in 3.0.1
    setNbt(@NotNull String key, boolean value)
    Sets NBT tag to the ItemStack
    setNbt(@NotNull String key, @NotNull String value)
    Sets NBT tag to the ItemStack
    setUnbreakable(boolean unbreakable)
    Deprecated.
    In favor of unbreakable(), nothing changed just the name, will be removed in 3.0.1
    Makes the ItemStack unbreakable
    unbreakable(boolean unbreakable)
    Sets the item as unbreakable

    Methods inherited from class java.lang.Object

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

    • BaseItemBuilder

      protected BaseItemBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
  • Method Details

    • name

      @NotNull @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

      @NotNull @Contract("_ -> this") public B amount(int amount)
      Sets the amount of items
      Parameters:
      amount - the amount of items
      Returns:
      ItemBuilder
      Since:
      3.0.0
    • lore

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

      @NotNull @Contract("_ -> this") public B lore(@NotNull @NotNull List<@Nullable 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

      @NotNull @Contract("_ -> this") public B lore(@NotNull @NotNull Consumer<List<@Nullable 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

      @NotNull @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

      @NotNull @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

      @NotNull @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
    • enchant

      @NotNull @Contract("_, _ -> this") public B enchant(@NotNull @NotNull Map<org.bukkit.enchantments.Enchantment,Integer> enchantments, boolean ignoreLevelRestriction)
      Enchants the ItemStack with the specified map where the value is the level of the key's enchantment
      Parameters:
      enchantments - Enchantments to add
      ignoreLevelRestriction - If level restriction should be ignored
      Returns:
      ItemBuilder
      Since:
      3.1.2
    • enchant

      @NotNull @Contract("_ -> this") public B enchant(@NotNull @NotNull Map<org.bukkit.enchantments.Enchantment,Integer> enchantments)
      Enchants the ItemStack with the specified map where the value is the level of the key's enchantment
      Parameters:
      enchantments - Enchantments to add
      Returns:
      ItemBuilder
      Since:
      3.1.2
    • disenchant

      @NotNull @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

      @NotNull @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

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

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

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

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

      @NotNull @Contract("_ -> this") public B pdc(@NotNull @NotNull 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

      @NotNull @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
    • color

      @NotNull @Contract("_ -> this") public B color(@NotNull @NotNull org.bukkit.Color color)
      Color an ItemStack
      Parameters:
      color - color
      Returns:
      BaseItemBuilder
      Since:
      3.0.3
      See Also:
      • LeatherArmorMeta.setColor(Color)
      • MapMeta.setColor(Color)
    • setNbt

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

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

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

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

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

      @NotNull @Contract("_ -> new") public @NotNull 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
    • getItemStack

      @NotNull protected @NotNull org.bukkit.inventory.ItemStack getItemStack()
      Package private getter for extended builders
      Returns:
      The ItemStack
    • setItemStack

      protected void setItemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Package private setter for the extended builders
      Parameters:
      itemStack - The ItemStack
    • getMeta

      @NotNull protected @NotNull org.bukkit.inventory.meta.ItemMeta getMeta()
      Package private getter for extended builders
      Returns:
      The ItemMeta
    • setMeta

      protected void setMeta(@NotNull @NotNull org.bukkit.inventory.meta.ItemMeta meta)
      Package private setter for the extended builders
      Parameters:
      meta - The ItemMeta
    • setName

      @Deprecated public B setName(@NotNull @NotNull String name)
      Deprecated.
      In favor of name(Component), will be removed in 3.0.1
      Set display name of the item
      Parameters:
      name - the display name of the item
      Returns:
      ItemBuilder
    • setAmount

      @Deprecated public B setAmount(int amount)
      Deprecated.
      In favor of amount(int), nothing changed just the name, will be removed in 3.0.1
      Sets the amount of items
      Parameters:
      amount - the amount of items
      Returns:
      ItemBuilder
    • addLore

      @Deprecated public B addLore(@NotNull @NotNull String... lore)
      Deprecated.
      In favor of lore(Consumer), will be removed in 3.0.1
      Add lore lines of an item
      Parameters:
      lore - the lore lines to add
      Returns:
      ItemBuilder
    • addLore

      @Deprecated public B addLore(@NotNull @NotNull List<String> lore)
      Deprecated.
      In favor of lore(Consumer), will be removed in 3.0.1
      Set lore lines of an item
      Parameters:
      lore - A List with the lore lines to add
      Returns:
      ItemBuilder
    • setLore

      @Deprecated public B setLore(@NotNull @NotNull String... lore)
      Deprecated.
      In favor of lore(Component...), will be removed in 3.0.1
      Set the lore lines of an item
      Parameters:
      lore - the lore lines to set
      Returns:
      ItemBuilder
    • setLore

      @Deprecated public B setLore(@NotNull @NotNull List<String> lore)
      Deprecated.
      In favor of lore(List), will be removed in 3.0.1
      Set the lore lines of an item
      Parameters:
      lore - A List with the lore lines
      Returns:
      ItemBuilder
    • addEnchantment

      @Deprecated public B addEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelRestriction)
      Deprecated.
      In favor of enchant(Enchantment, int, boolean), nothing changed just the name, will be removed in 3.0.1
      Add enchantment to an item
      Parameters:
      enchantment - the Enchantment to add
      level - the level of the Enchantment
      ignoreLevelRestriction - If should or not ignore it
      Returns:
      ItemBuilder
    • addEnchantment

      @Deprecated public B addEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
      Deprecated.
      In favor of enchant(Enchantment, int), nothing changed just the name, will be removed in 3.0.1
      Add enchantment to an item
      Parameters:
      enchantment - the Enchantment to add
      level - the level of the Enchantment
      Returns:
      ItemBuilder
    • addEnchantment

      @Deprecated public B addEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Deprecated.
      In favor of enchant(Enchantment), nothing changed just the name, will be removed in 3.0.1
      Add enchantment to an item
      Parameters:
      enchantment - the Enchantment to add
      Returns:
      ItemBuilder
    • removeEnchantment

      @Deprecated public B removeEnchantment(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Deprecated.
      In favor of disenchant(Enchantment), nothing changed just the name, will be removed in 3.0.1
      Removes a certain Enchantment from the item
      Parameters:
      enchantment - The Enchantment to remove
      Returns:
      ItemBuilder
    • addItemFlags

      @Deprecated public B addItemFlags(@NotNull @NotNull org.bukkit.inventory.ItemFlag... flags)
      Deprecated.
      In favor of flags(ItemFlag...), nothing changed just the name, will be removed in 3.0.1
      Add a custom ItemFlag to the item
      Parameters:
      flags - the ItemFlag to add
      Returns:
      ItemBuilder
    • setUnbreakable

      @Deprecated public B setUnbreakable(boolean unbreakable)
      Deprecated.
      In favor of unbreakable(), nothing changed just the name, will be removed in 3.0.1
      Sets the item as unbreakable
      Parameters:
      unbreakable - If should or not be unbreakable
      Returns:
      ItemBuilder