Class ItemBuilder

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
Direct Known Subclasses:
ArmorBuilder, AxolotlBucketBuilder, BannerBuilder, BundleBuilder, CompassBuilder, CrossbowBuilder, DamageableItemBuilder, EnchantmentStorageBuilder, FireworkBuilder, FireworkEffectBuilder, KnowledgeBookBuilder, LeatherArmorBuilder, MapBuilder, MusicInstrumentBuilder, OminousBottleBuilder, PotionBuilder, RepairableBuilder, ShieldBuilder, SkullBuilder, SpawnEggBuilder, SuspiciousStewBuilder, TropicalFishBucketBuilder, WritableBookBuilder

public class ItemBuilder extends Object
A utility class for building and modifying ItemStack objects in Minecraft. Supports setting item material, amount, display names, and more.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ItemBuilder(@NotNull org.bukkit.Material material)
    Creates an ItemBuilder with a specified Material and a default amount of 1.
    ItemBuilder(@NotNull org.bukkit.Material material, int amount)
    Creates an ItemBuilder with a specified Material and amount.
    ItemBuilder(@NotNull org.bukkit.inventory.ItemStack itemStack)
    Creates an ItemBuilder from an existing ItemStack.
  • Method Summary

    Modifier and Type
    Method
    Description
    addAttributeModifier(@NotNull org.bukkit.attribute.Attribute attribute, @NotNull org.bukkit.attribute.AttributeModifier modifier)
    Add an Attribute and it's Modifier.
    addEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Adds an enchantment to the item with level 1 and level limit check.
    addEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
    Adds or updates an enchantment on the item with level limit check.
    addEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelLimit)
    Adds or updates an enchantment on the item.
    addItemFlags(@NotNull org.bukkit.inventory.ItemFlag... itemFlags)
    Adds the specified item flags to the item.
    addLore(@NotNull String lore)
    Adds a single lore line to the item.
    @NotNull org.bukkit.inventory.ItemStack
    Builds and returns the final ItemStack.
    int
    Gets the number of items in the stack.
    @Nullable com.google.common.collect.Multimap<org.bukkit.attribute.Attribute,org.bukkit.attribute.AttributeModifier>
    Return an immutable copy of all Attributes and their modifiers in this ItemMeta.
    @Nullable Collection<org.bukkit.attribute.AttributeModifier>
    getAttributeModifiers(@NotNull org.bukkit.attribute.Attribute attribute)
    Return an immutable copy of all AttributeModifiers for a given Attribute
    @NotNull com.google.common.collect.Multimap<org.bukkit.attribute.Attribute,org.bukkit.attribute.AttributeModifier>
    getAttributeModifiers(@NotNull org.bukkit.inventory.EquipmentSlot slot)
    Return an immutable copy of all Attributes and their AttributeModifiers for a given EquipmentSlot.
    int
    Gets the Custom Model Data of the item.
    @Nullable org.bukkit.Tag<org.bukkit.damage.DamageType>
    Gets the damage resistance tag of the item.
    Gets the display name of the item.
    int
    Gets the enchantable value of the item.
    int
    getEnchantLevel(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Gets the level of a specific enchantment on the item.
    @Nullable Boolean
    Gets the enchantment glint override status of the item.
    @NotNull Map<org.bukkit.enchantments.Enchantment,Integer>
    Gets all enchantments on the item.
    @NotNull org.bukkit.inventory.meta.components.EquippableComponent
    Gets the equippable component of the item.
    @NotNull org.bukkit.inventory.meta.components.FoodComponent
    Gets the food component associated with this item, or creates an empty food instance.
    @NotNull Set<org.bukkit.inventory.ItemFlag>
    Gets all item flags present on the item.
    @NotNull org.bukkit.inventory.meta.ItemMeta
     
    @Nullable org.bukkit.NamespacedKey
    Gets the item model of the item.
    @Nullable org.bukkit.inventory.meta.components.JukeboxPlayableComponent
    Gets the JukeboxPlayableComponent of the item.
    int
    Gets the max stack size of the item.
    @NotNull org.bukkit.inventory.ItemRarity
    Gets the rarity of the item.
    @NotNull org.bukkit.inventory.meta.components.ToolComponent
    Gets the ToolComponent of the item.
    @Nullable org.bukkit.NamespacedKey
    Gets the tooltip style of the item.
    @NotNull String
    Gets the translation key for this item, used for localization.
    @NotNull org.bukkit.Material
    Gets the type of material of the item stack.
    @NotNull org.bukkit.inventory.meta.components.UseCooldownComponent
    Gets the cooldown component associated with this item, or creates an empty cooldown instance.
    @Nullable org.bukkit.inventory.ItemStack
    Gets the item that remains after using this item, if any.
    boolean
    Checks if the ItemMeta has any attribute modifiers.
    boolean
    hasConflictingEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Checks if an enchantment conflicts with any existing enchantments on the item.
    boolean
    Checks if the item has a Custom Model Data set.
    boolean
    Checks if the item has damage resistance.
    boolean
    hasEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Checks if the item has a specific enchantment.
    boolean
    Checks if the item has an enchantable value set.
    boolean
    Checks if the item has an enchantment glint override.
    boolean
    Checks if the item has any enchantments.
    boolean
    Checks whether the item has an equippable component.
    boolean
    Checks if the item has a food component.
    boolean
    hasItemFlag(@NotNull org.bukkit.inventory.ItemFlag flag)
    Checks if a specific item flag is present on the item.
    boolean
    Checks if the item has a custom item model.
    boolean
    Checks if the item has a JukeboxPlayableComponent.
    boolean
    Checks if the item has a custom max stack size.
    boolean
    Checks if the item has a custom rarity.
    boolean
    Checks if the item has a ToolComponent attached.
    boolean
    Checks if the item has a tooltip style.
    boolean
    Checks if the item has a use cooldown component.
    boolean
    Checks if the item has a use remainder.
    Hides all item flags from the item.
    insertLore(@NotNull String lore, int index)
    Inserts a lore line at a specified index.
    boolean
    Checks if the item is a glider.
    boolean
    Checks if the item has tooltips hidden.
    boolean
    Checks if the item is unbreakable.
    removeAttributeModifier(@NotNull org.bukkit.attribute.Attribute attribute)
    Remove all AttributeModifiers associated with the given Attribute.
    removeAttributeModifier(@NotNull org.bukkit.attribute.Attribute attribute, @NotNull org.bukkit.attribute.AttributeModifier modifier)
    Remove a specific Attribute and AttributeModifier.
    removeAttributeModifier(@NotNull org.bukkit.inventory.EquipmentSlot slot)
    Remove all Attributes and AttributeModifiers for a given EquipmentSlot.
    removeEnchant(@NotNull org.bukkit.enchantments.Enchantment enchantment)
    Removes a specific enchantment from the item.
    Removes all enchantments from the item.
    removeItemFlags(@NotNull org.bukkit.inventory.ItemFlag... itemFlags)
    Removes the specified item flags from the item.
    replaceLore(@NotNull String from, @NotNull String to)
    Replaces occurrences of a specific substring in the item's lore.
    setAmount(int amount)
    Sets the number of items in the stack.
    setAttributeModifiers(@Nullable com.google.common.collect.Multimap<org.bukkit.attribute.Attribute,org.bukkit.attribute.AttributeModifier> attributeModifiers)
    Set all Attributes and their AttributeModifiers.
    Sets the Custom Model Data for the item.
    setDamageResistant(@Nullable org.bukkit.Tag<org.bukkit.damage.DamageType> tag)
    Sets the damage resistance tag of the item.
    Sets the display name of the item.
    setEnchantable(@Nullable Integer enchantable)
    Sets the enchantable value of the item.
    Sets or removes the enchantment glint override.
    setEquippableComponent(org.bukkit.inventory.EquipmentSlot equipmentSlot)
    Creates and sets a custom equippable component for the item using the specified equipment slot.
    setEquippableComponent(@Nullable org.bukkit.inventory.meta.components.EquippableComponent equippable)
    Sets the equippable component for the item.
    setFood(int nutrition, float saturation, boolean canEatOnFull)
    Creates and sets a custom food component for this item.
    setFoodComponent(@Nullable org.bukkit.inventory.meta.components.FoodComponent food)
    Sets the food component for this item.
    setGlider(boolean glider)
    Sets the glider status of the item.
    setHideTooltip(boolean hideTooltip)
    Sets whether tooltips should be hidden for the item.
    setItemModel(@NotNull String value)
    Sets the item model of the item using a string.
    setItemModel(@Nullable org.bukkit.NamespacedKey itemModel)
    Sets the item model of the item.
    setJukeboxPlayableComponent(String keyValue, org.bukkit.JukeboxSong jukeboxSong, boolean showInTooltip)
    Creates and sets a custom JukeboxPlayableComponent using a key value string, song, and tooltip visibility.
    setJukeboxPlayableComponent(@Nullable org.bukkit.inventory.meta.components.JukeboxPlayableComponent jukeboxPlayable)
    Sets the JukeboxPlayableComponent of the item.
    setJukeboxPlayableComponent(org.bukkit.NamespacedKey songKey, org.bukkit.JukeboxSong jukeboxSong, boolean showInTooltip)
    Creates and sets a custom JukeboxPlayableComponent using a song key, song, and tooltip visibility.
    setLores(String... lores)
    Sets the lore of the item using an array of strings.
    Sets the lore of the item using a list of strings.
    setMaxStackSize(@Nullable Integer max)
    Sets the max stack size of the item.
    setRarity(@Nullable org.bukkit.inventory.ItemRarity rarity)
    Sets the rarity of the item.
    setToolComponent(float defaultMiningSpeed, int damagePerBlock)
    Creates and sets a new CustomToolComponent for the item with the specified default mining speed and damage per block.
    setToolComponent(@Nullable org.bukkit.inventory.meta.components.ToolComponent tool)
    Sets the ToolComponent for the item.
    setTooltipStyle(@NotNull String value)
    Sets the tooltip style of the item using a string.
    setTooltipStyle(@Nullable org.bukkit.NamespacedKey tooltipStyle)
    Sets the tooltip style of the item.
    setType(@NotNull org.bukkit.Material material)
    Sets the type of the item stack.
    setUnbreakable(boolean unbreakable)
    Sets the unbreakable status of the item.
    setUseCooldownComponent(float cooldownSeconds, @NotNull String keyValue)
    Creates and sets a custom use cooldown for this item using a string value for the namespace key.
    setUseCooldownComponent(float cooldownSeconds, @NotNull org.bukkit.NamespacedKey cooldownGroup)
    Sets a custom use cooldown for this item.
    setUseCooldownComponent(@Nullable org.bukkit.inventory.meta.components.UseCooldownComponent cooldown)
    Sets the cooldown component for this item.
    setUseRemainder(@Nullable org.bukkit.inventory.ItemStack remainder)
    Sets the item that will remain after using this item.

    Methods inherited from class java.lang.Object

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

    • ItemBuilder

      public ItemBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Creates an ItemBuilder from an existing ItemStack.
      Parameters:
      itemStack - the ItemStack to clone and modify
      Throws:
      NullPointerException - if itemStack is null
    • ItemBuilder

      public ItemBuilder(@NotNull @NotNull org.bukkit.Material material, int amount)
      Creates an ItemBuilder with a specified Material and amount.
      Parameters:
      material - the material of the item
      amount - the quantity of items (must be between 1 and 127)
      Throws:
      IllegalArgumentException - if the amount is less than 1 or greater than 127
      NullPointerException - if material is null
    • ItemBuilder

      public ItemBuilder(@NotNull @NotNull org.bukkit.Material material)
      Creates an ItemBuilder with a specified Material and a default amount of 1.
      Parameters:
      material - the material of the item
      Throws:
      IllegalArgumentException - if material is air
      NullPointerException - if material is null
  • Method Details

    • build

      @NotNull public @NotNull org.bukkit.inventory.ItemStack build()
      Builds and returns the final ItemStack.
      Returns:
      a clone of the constructed ItemStack
    • setAmount

      public ItemBuilder setAmount(int amount)
      Sets the number of items in the stack.
      Parameters:
      amount - the number of items must be between 1 and 127 (inclusive)
      Returns:
      this ItemBuilder instance for method chaining
      Throws:
      IllegalArgumentException - if the amount is less than 1 or greater than 127
    • getAmount

      public int getAmount()
      Gets the number of items in the stack.
      Returns:
      the number of items in the stack
    • setType

      public ItemBuilder setType(@NotNull @NotNull org.bukkit.Material material)
      Sets the type of the item stack.
      Parameters:
      material - the material to set, must not be air
      Returns:
      this ItemBuilder instance for method chaining
      Throws:
      IllegalArgumentException - if the material is air
    • getType

      @NotNull public @NotNull org.bukkit.Material getType()
      Gets the type of material of the item stack.
      Returns:
      the material type of the item stack
    • getTranslationKey

      @NotNull public @NotNull String getTranslationKey()
      Gets the translation key for this item, used for localization.
      Returns:
      the translation key for the item
    • setDisplayName

      public ItemBuilder setDisplayName(String name)
      Sets the display name of the item.
      Parameters:
      name - the new display name can be null to remove the display name
      Returns:
      the current ItemBuilder instance for method chaining
    • getDisplayName

      public String getDisplayName()
      Gets the display name of the item.
      Returns:
      the display name if a set, or the default item translation key if not
    • setLores

      public ItemBuilder setLores(List<String> lores)
      Sets the lore of the item using a list of strings.
      Parameters:
      lores - the list of lore strings to set
      Returns:
      the current ItemBuilder instance for method chaining
    • setLores

      public ItemBuilder setLores(String... lores)
      Sets the lore of the item using an array of strings.
      Parameters:
      lores - the array of lore strings to set
      Returns:
      the current ItemBuilder instance for method chaining
    • replaceLore

      public ItemBuilder replaceLore(@NotNull @NotNull String from, @NotNull @NotNull String to)
      Replaces occurrences of a specific substring in the item's lore.
      Parameters:
      from - the substring to replace
      to - the substring to replace with
      Returns:
      the current ItemBuilder instance for method chaining
    • addLore

      public ItemBuilder addLore(@NotNull @NotNull String lore)
      Adds a single lore line to the item.
      Parameters:
      lore - the lore string to add
      Returns:
      the current ItemBuilder instance for method chaining
    • insertLore

      public ItemBuilder insertLore(@NotNull @NotNull String lore, int index)
      Inserts a lore line at a specified index.
      Parameters:
      lore - the lore string to insert
      index - the position to insert the lore at
      Returns:
      the current ItemBuilder instance for method chaining
      Throws:
      IllegalArgumentException - if the index is negative
    • hasCustomModelData

      public boolean hasCustomModelData()
      Checks if the item has a Custom Model Data set.
      Returns:
      true if the item has Custom Model Data, false otherwise
    • getCustomModelData

      public int getCustomModelData()
      Gets the Custom Model Data of the item.
      Returns:
      the Custom Model Data value
      Throws:
      IllegalArgumentException - if the item does not have Custom Model Data
    • setCustomModelData

      public ItemBuilder setCustomModelData(Integer data)
      Sets the Custom Model Data for the item.
      Parameters:
      data - the Custom Model Data to set, or null to remove it
      Returns:
      the current ItemBuilder instance for method chaining
    • hasEnchantable

      public boolean hasEnchantable()
      Checks if the item has an enchantable value set.
      Returns:
      true if the item has an enchantable value, false otherwise
    • getEnchantable

      public int getEnchantable()
      Gets the enchantable value of the item.
      Returns:
      the enchantable value
    • setEnchantable

      public ItemBuilder setEnchantable(@Nullable @Nullable Integer enchantable)
      Sets the enchantable value of the item. If null is provided, the enchantable value will be removed.
      Parameters:
      enchantable - the enchantable value to set, or null to remove it
      Returns:
      the current ItemBuilder instance for method chaining
    • hasEnchants

      public boolean hasEnchants()
      Checks if the item has any enchantments.
      Returns:
      true if the item has enchantments, false otherwise
    • hasEnchant

      public boolean hasEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Checks if the item has a specific enchantment.
      Parameters:
      enchantment - the enchantment to check for
      Returns:
      true if the item has the specified enchantment, false otherwise
    • getEnchantLevel

      public int getEnchantLevel(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Gets the level of a specific enchantment on the item.
      Parameters:
      enchantment - the enchantment to check
      Returns:
      the level of the enchantment
    • getEnchants

      @NotNull public @NotNull Map<org.bukkit.enchantments.Enchantment,Integer> getEnchants()
      Gets all enchantments on the item.
      Returns:
      a map of enchantments and their levels
    • addEnchant

      public ItemBuilder addEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level, boolean ignoreLevelLimit)
      Adds or updates an enchantment on the item. If the level is 0, the enchantment will be removed.
      Parameters:
      enchantment - the enchantment to add or update
      level - the level of the enchantment
      ignoreLevelLimit - whether to bypass level restrictions
      Returns:
      the current ItemBuilder instance for method chaining
    • addEnchant

      public ItemBuilder addEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment, int level)
      Adds or updates an enchantment on the item with level limit check.
      Parameters:
      enchantment - the enchantment to add or update
      level - the level of the enchantment
      Returns:
      the current ItemBuilder instance for method chaining
    • addEnchant

      public ItemBuilder addEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Adds an enchantment to the item with level 1 and level limit check.
      Parameters:
      enchantment - the enchantment to add
      Returns:
      the current ItemBuilder instance for method chaining
    • removeEnchant

      public ItemBuilder removeEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Removes a specific enchantment from the item.
      Parameters:
      enchantment - the enchantment to remove
      Returns:
      the current ItemBuilder instance for method chaining
    • removeEnchants

      public ItemBuilder removeEnchants()
      Removes all enchantments from the item.
      Returns:
      the current ItemBuilder instance for method chaining
    • hasConflictingEnchant

      public boolean hasConflictingEnchant(@NotNull @NotNull org.bukkit.enchantments.Enchantment enchantment)
      Checks if an enchantment conflicts with any existing enchantments on the item.
      Parameters:
      enchantment - the enchantment to check
      Returns:
      true if there is a conflict, false otherwise
    • addItemFlags

      public ItemBuilder addItemFlags(@NotNull @NotNull org.bukkit.inventory.ItemFlag... itemFlags)
      Adds the specified item flags to the item. If HIDE_ATTRIBUTES are added and Paper API is available, default attributes are set.
      Parameters:
      itemFlags - the item flags to add
      Returns:
      the current ItemBuilder instance for method chaining
    • removeItemFlags

      public ItemBuilder removeItemFlags(@NotNull @NotNull org.bukkit.inventory.ItemFlag... itemFlags)
      Removes the specified item flags from the item. If HIDE_ATTRIBUTES are removed and Paper API is available, default attributes are cleared.
      Parameters:
      itemFlags - the item flags to remove
      Returns:
      the current ItemBuilder instance for method chaining
    • hideAllItemFlags

      public ItemBuilder hideAllItemFlags()
      Hides all item flags from the item. If Paper API is available and the item has no attribute modifiers, default attributes are set.
      Returns:
      the current ItemBuilder instance for method chaining
    • getItemFlags

      @NotNull public @NotNull Set<org.bukkit.inventory.ItemFlag> getItemFlags()
      Gets all item flags present on the item.
      Returns:
      a set of item flags
    • hasItemFlag

      public boolean hasItemFlag(@NotNull @NotNull org.bukkit.inventory.ItemFlag flag)
      Checks if a specific item flag is present on the item.
      Parameters:
      flag - the item flag to check for
      Returns:
      true if the item contains the specified flag, false otherwise
    • isHideTooltip

      public boolean isHideTooltip()
      Checks if the item has tooltips hidden.
      Returns:
      true if tooltips are hidden, false otherwise
    • setHideTooltip

      public ItemBuilder setHideTooltip(boolean hideTooltip)
      Sets whether tooltips should be hidden for the item.
      Parameters:
      hideTooltip - true to hide tooltips, false to show them
      Returns:
      the current ItemBuilder instance for method chaining
    • hasTooltipStyle

      public boolean hasTooltipStyle()
      Checks if the item has a tooltip style.
      Returns:
      true if the item has a tooltip style, false otherwise
    • getTooltipStyle

      @Nullable public @Nullable org.bukkit.NamespacedKey getTooltipStyle()
      Gets the tooltip style of the item.
      Returns:
      the tooltip style as a NamespacedKey, or null if not set
    • setTooltipStyle

      public ItemBuilder setTooltipStyle(@Nullable @Nullable org.bukkit.NamespacedKey tooltipStyle)
      Sets the tooltip style of the item.
      Parameters:
      tooltipStyle - the NamespacedKey for the tooltip style, or null to remove it
      Returns:
      the current ItemBuilder instance for method chaining
    • setTooltipStyle

      public ItemBuilder setTooltipStyle(@NotNull @NotNull String value)
      Sets the tooltip style of the item using a string. If the string does not contain a namespace, "minecraft" is used by default.
      Parameters:
      value - the string representing the tooltip style
      Returns:
      the current ItemBuilder instance for method chaining
    • hasItemModel

      public boolean hasItemModel()
      Checks if the item has a custom item model.
      Returns:
      true if the item has a custom item model, false otherwise
    • getItemModel

      @Nullable public @Nullable org.bukkit.NamespacedKey getItemModel()
      Gets the item model of the item.
      Returns:
      the item model as a NamespacedKey, or null if not set
    • setItemModel

      public ItemBuilder setItemModel(@Nullable @Nullable org.bukkit.NamespacedKey itemModel)
      Sets the item model of the item.
      Parameters:
      itemModel - the NamespacedKey for the item model, or null to remove it
      Returns:
      the current ItemBuilder instance for method chaining
    • setItemModel

      public ItemBuilder setItemModel(@NotNull @NotNull String value)
      Sets the item model of the item using a string. If the string does not contain a namespace, "minecraft" is used by default.
      Parameters:
      value - the string representing the item model
      Returns:
      the current ItemBuilder instance for method chaining
    • isUnbreakable

      public boolean isUnbreakable()
      Checks if the item is unbreakable.
      Returns:
      true if the item is unbreakable, false otherwise
    • setUnbreakable

      public ItemBuilder setUnbreakable(boolean unbreakable)
      Sets the unbreakable status of the item.
      Parameters:
      unbreakable - true to make the item unbreakable, false otherwise
      Returns:
      the current ItemBuilder instance for method chaining
    • hasEnchantmentGlintOverride

      public boolean hasEnchantmentGlintOverride()
      Checks if the item has an enchantment glint override.
      Returns:
      true, if the item has an enchantment glint override, false otherwise
    • getEnchantmentGlintOverride

      @Nullable public @Nullable Boolean getEnchantmentGlintOverride()
      Gets the enchantment glint override status of the item.
      Returns:
      true if the glint is overridden, false if not, or null if unset
    • setEnchantmentGlintOverride

      public ItemBuilder setEnchantmentGlintOverride(@Nullable @Nullable Boolean override)
      Sets or removes the enchantment glint override.
      Parameters:
      override - true to enable the glint, false to disable it, or null to remove the override
      Returns:
      the current ItemBuilder instance for method chaining
    • isGlider

      public boolean isGlider()
      Checks if the item is a glider.
      Returns:
      true if the item is a glider, false otherwise
    • setGlider

      public ItemBuilder setGlider(boolean glider)
      Sets the glider status of the item.
      Parameters:
      glider - true to make the item a glider, false otherwise
      Returns:
      the current ItemBuilder instance for method chaining
    • hasDamageResistant

      public boolean hasDamageResistant()
      Checks if the item has damage resistance.
      Returns:
      true if the item has damage resistance, false otherwise
    • getDamageResistant

      @Nullable public @Nullable org.bukkit.Tag<org.bukkit.damage.DamageType> getDamageResistant()
      Gets the damage resistance tag of the item.
      Returns:
      the damage resistance tag as a org.bukkit.Tag<org.bukkit.damage.DamageType>, or null if not set
    • setDamageResistant

      public ItemBuilder setDamageResistant(@Nullable @Nullable org.bukkit.Tag<org.bukkit.damage.DamageType> tag)
      Sets the damage resistance tag of the item.
      Parameters:
      tag - the org.bukkit.Tag<org.bukkit.damage.DamageType> for damage resistance, or null to remove it
      Returns:
      the current ItemBuilder instance for method chaining
    • hasMaxStackSize

      public boolean hasMaxStackSize()
      Checks if the item has a custom max stack size.
      Returns:
      true if the item has a custom max stack size, false otherwise
    • getMaxStackSize

      public int getMaxStackSize()
      Gets the max stack size of the item.
      Returns:
      the max stack size, or the default stack size if not set
    • setMaxStackSize

      public ItemBuilder setMaxStackSize(@Nullable @Nullable Integer max)
      Sets the max stack size of the item.
      Parameters:
      max - the new max stack size, or null to reset to the default stack size
      Returns:
      the current ItemBuilder instance for method chaining
      Throws:
      IllegalArgumentException - if the max stack size is not between 1 and 99
    • hasRarity

      public boolean hasRarity()
      Checks if the item has a custom rarity.
      Returns:
      true if the item has a custom rarity, false otherwise
    • getRarity

      @NotNull public @NotNull org.bukkit.inventory.ItemRarity getRarity()
      Gets the rarity of the item.
      Returns:
      the item's rarity, or ItemRarity. COMMON if not set
    • setRarity

      public ItemBuilder setRarity(@Nullable @Nullable org.bukkit.inventory.ItemRarity rarity)
      Sets the rarity of the item.
      Parameters:
      rarity - the ItemRarity to set, or null to remove the custom rarity
      Returns:
      the current ItemBuilder instance for method chaining
    • hasUseRemainder

      public boolean hasUseRemainder()
      Checks if the item has a use remainder.
      Returns:
      true if the item has a use remainder, false otherwise.
    • getUseRemainder

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getUseRemainder()
      Gets the item that remains after using this item, if any.
      Returns:
      the remainder ItemStack, or null if there is none.
    • setUseRemainder

      public ItemBuilder setUseRemainder(@Nullable @Nullable org.bukkit.inventory.ItemStack remainder)
      Sets the item that will remain after using this item.
      Parameters:
      remainder - the ItemStack to set as the use remainder, or null to remove it.
      Returns:
      the current ItemBuilder instance for chaining.
    • hasUseCooldownComponent

      public boolean hasUseCooldownComponent()
      Checks if the item has a use cooldown component.
      Returns:
      true if the item has a use cooldown, false otherwise.
    • getUseCooldownComponent

      @NotNull public @NotNull org.bukkit.inventory.meta.components.UseCooldownComponent getUseCooldownComponent()
      Gets the cooldown component associated with this item, or creates an empty cooldown instance.
      Returns:
      the UseCooldownComponent set on this item, or creates an empty cooldown instance.
    • setUseCooldownComponent

      public ItemBuilder setUseCooldownComponent(@Nullable @Nullable org.bukkit.inventory.meta.components.UseCooldownComponent cooldown)
      Sets the cooldown component for this item.
      Parameters:
      cooldown - the UseCooldownComponent to set, or null to remove the cooldown.
      Returns:
      the current ItemBuilder instance for chaining.
    • setUseCooldownComponent

      public ItemBuilder setUseCooldownComponent(float cooldownSeconds, @NotNull @NotNull org.bukkit.NamespacedKey cooldownGroup)
      Sets a custom use cooldown for this item.
      Parameters:
      cooldownSeconds - the cooldown duration in seconds.
      cooldownGroup - the NamespacedKey representing the cooldown group.
      Returns:
      the current ItemBuilder instance for chaining.
    • setUseCooldownComponent

      public ItemBuilder setUseCooldownComponent(float cooldownSeconds, @NotNull @NotNull String keyValue)
      Creates and sets a custom use cooldown for this item using a string value for the namespace key.
      Parameters:
      cooldownSeconds - the cooldown duration in seconds.
      keyValue - the string representation of the NamespacedKey.
      Returns:
      the current ItemBuilder instance for chaining.
    • hasFoodComponent

      public boolean hasFoodComponent()
      Checks if the item has a food component.
      Returns:
      true if the item has a food component, false otherwise.
    • getFoodComponent

      @NotNull public @NotNull org.bukkit.inventory.meta.components.FoodComponent getFoodComponent()
      Gets the food component associated with this item, or creates an empty food instance.
      Returns:
      the FoodComponent, or creates an empty food instance.
    • setFoodComponent

      public ItemBuilder setFoodComponent(@Nullable @Nullable org.bukkit.inventory.meta.components.FoodComponent food)
      Sets the food component for this item.
      Parameters:
      food - the FoodComponent to set, or null to remove it.
      Returns:
      the current ItemBuilder instance for chaining.
    • setFood

      public ItemBuilder setFood(int nutrition, float saturation, boolean canEatOnFull)
      Creates and sets a custom food component for this item.
      Parameters:
      nutrition - the amount of nutrition the food provides.
      saturation - the saturation modifier of the food.
      canEatOnFull - whether the food can be eaten even if the player is not hungry.
      Returns:
      the current ItemBuilder instance for chaining.
    • hasToolComponent

      public boolean hasToolComponent()
      Checks if the item has a ToolComponent attached.
      Returns:
      true if the item has a ToolComponent, false otherwise
    • getToolComponent

      @NotNull public @NotNull org.bukkit.inventory.meta.components.ToolComponent getToolComponent()
      Gets the ToolComponent of the item.
      Returns:
      the ToolComponent associated with this item
      Throws:
      NullPointerException - if the item does not have a ToolComponent
    • setToolComponent

      public ItemBuilder setToolComponent(@Nullable @Nullable org.bukkit.inventory.meta.components.ToolComponent tool)
      Sets the ToolComponent for the item.
      Parameters:
      tool - the ToolComponent to set, or null to remove the existing ToolComponent
      Returns:
      this ItemBuilder instance for method chaining
    • setToolComponent

      public ItemBuilder setToolComponent(float defaultMiningSpeed, int damagePerBlock)
      Creates and sets a new CustomToolComponent for the item with the specified default mining speed and damage per block.
      Parameters:
      defaultMiningSpeed - the default mining speed of the tool
      damagePerBlock - the amount of damage the tool takes per block broken
      Returns:
      this ItemBuilder instance for method chaining
    • hasEquippableComponent

      public boolean hasEquippableComponent()
      Checks whether the item has an equippable component.
      Returns:
      true if the item has an equippable component, false otherwise
    • getEquippableComponent

      @NotNull public @NotNull org.bukkit.inventory.meta.components.EquippableComponent getEquippableComponent()
      Gets the equippable component of the item.
      Returns:
      the equippable component, never null
    • setEquippableComponent

      public ItemBuilder setEquippableComponent(@Nullable @Nullable org.bukkit.inventory.meta.components.EquippableComponent equippable)
      Sets the equippable component for the item.
      Parameters:
      equippable - the equippable component to set, or null to remove it
      Returns:
      the current ItemBuilder instance for chaining
    • setEquippableComponent

      public ItemBuilder setEquippableComponent(org.bukkit.inventory.EquipmentSlot equipmentSlot)
      Creates and sets a custom equippable component for the item using the specified equipment slot.
      Parameters:
      equipmentSlot - the slot where the item can be equipped
      Returns:
      the current ItemBuilder instance for chaining
    • hasJukeboxPlayableComponent

      public boolean hasJukeboxPlayableComponent()
      Checks if the item has a JukeboxPlayableComponent.
      Returns:
      true if the item has a JukeboxPlayableComponent, false otherwise
    • getJukeboxPlayableComponent

      @Nullable public @Nullable org.bukkit.inventory.meta.components.JukeboxPlayableComponent getJukeboxPlayableComponent()
      Gets the JukeboxPlayableComponent of the item.
      Returns:
      the JukeboxPlayableComponent, or null if not present
    • setJukeboxPlayableComponent

      public ItemBuilder setJukeboxPlayableComponent(@Nullable @Nullable org.bukkit.inventory.meta.components.JukeboxPlayableComponent jukeboxPlayable)
      Sets the JukeboxPlayableComponent of the item.
      Parameters:
      jukeboxPlayable - the JukeboxPlayableComponent to set, or null to remove it
      Returns:
      the current ItemBuilder instance for chaining
    • setJukeboxPlayableComponent

      public ItemBuilder setJukeboxPlayableComponent(org.bukkit.NamespacedKey songKey, org.bukkit.JukeboxSong jukeboxSong, boolean showInTooltip)
      Creates and sets a custom JukeboxPlayableComponent using a song key, song, and tooltip visibility.
      Parameters:
      songKey - the key identifying the song
      jukeboxSong - the JukeboxSong to be played
      showInTooltip - whether the song should be shown in the item's tooltip
      Returns:
      the current ItemBuilder instance for chaining
    • setJukeboxPlayableComponent

      public ItemBuilder setJukeboxPlayableComponent(String keyValue, org.bukkit.JukeboxSong jukeboxSong, boolean showInTooltip)
      Creates and sets a custom JukeboxPlayableComponent using a key value string, song, and tooltip visibility.
      Parameters:
      keyValue - the string representation of the song's key (to be converted to a NamespacedKey)
      jukeboxSong - the JukeboxSong to be played
      showInTooltip - whether the song should be shown in the item's tooltip
      Returns:
      the current ItemBuilder instance for chaining
    • hasAttributeModifiers

      public boolean hasAttributeModifiers()
      Checks if the ItemMeta has any attribute modifiers.
      Returns:
      true if attribute modifiers exist, false otherwise.
    • getAttributeModifiers

      @Nullable public @Nullable com.google.common.collect.Multimap<org.bukkit.attribute.Attribute,org.bukkit.attribute.AttributeModifier> getAttributeModifiers()
      Return an immutable copy of all Attributes and their modifiers in this ItemMeta. Returns null if none exist.
      Returns:
      A Multimap containing attributes and their respective modifiers, or null if none exist.
    • getAttributeModifiers

      @NotNull public @NotNull com.google.common.collect.Multimap<org.bukkit.attribute.Attribute,org.bukkit.attribute.AttributeModifier> getAttributeModifiers(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot slot)
      Return an immutable copy of all Attributes and their AttributeModifiers for a given EquipmentSlot. Any AttributeModifier that does have a given EquipmentSlot will be returned. This is because AttributeModifiers without a slot are active in any slot. If there are no attributes set for the given slot, an empty map will be returned.
      Parameters:
      slot - The EquipmentSlot to filter attribute modifiers for.
      Returns:
      A non-null Multimap containing attributes and their modifiers for the specified slot.
    • getAttributeModifiers

      @Nullable public @Nullable Collection<org.bukkit.attribute.AttributeModifier> getAttributeModifiers(@NotNull @NotNull org.bukkit.attribute.Attribute attribute)
      Return an immutable copy of all AttributeModifiers for a given Attribute
      Parameters:
      attribute - The Attribute to retrieve modifiers for.
      Returns:
      A collection of AttributeModifiers associated with the given attribute, or null if none exist.
    • addAttributeModifier

      public ItemBuilder addAttributeModifier(@NotNull @NotNull org.bukkit.attribute.Attribute attribute, @NotNull @NotNull org.bukkit.attribute.AttributeModifier modifier)
      Add an Attribute and it's Modifier. AttributeModifiers can now support EquipmentSlots. If not set, the AttributeModifier will be active in ALL slots. Two AttributeModifiers that have the same UUID cannot exist on the same Attribute.
      Parameters:
      attribute - The Attribute to modify.
      modifier - The AttributeModifier specifying the modification.
      Returns:
      The current ItemBuilder instance for method chaining.
    • setAttributeModifiers

      public ItemBuilder setAttributeModifiers(@Nullable @Nullable com.google.common.collect.Multimap<org.bukkit.attribute.Attribute,org.bukkit.attribute.AttributeModifier> attributeModifiers)
      Set all Attributes and their AttributeModifiers. To clear all currently set Attributes and AttributeModifiers use null or an empty Multimap. If not null nor empty, this will filter all entries that are not null and add them to the ItemStack.
      Parameters:
      attributeModifiers - The new Multimap of attributes and their modifiers, or null to clear all modifiers.
      Returns:
      The current ItemBuilder instance for method chaining.
    • removeAttributeModifier

      public ItemBuilder removeAttributeModifier(@NotNull @NotNull org.bukkit.attribute.Attribute attribute)
      Remove all AttributeModifiers associated with the given Attribute.
      Parameters:
      attribute - The Attribute to remove all modifiers for.
      Returns:
      The current ItemBuilder instance for method chaining.
    • removeAttributeModifier

      public ItemBuilder removeAttributeModifier(@NotNull @NotNull org.bukkit.inventory.EquipmentSlot slot)
      Remove all Attributes and AttributeModifiers for a given EquipmentSlot. If the given EquipmentSlot is null, this will remove all AttributeModifiers that do not have an EquipmentSlot set.
      Parameters:
      slot - The EquipmentSlot to clear all attributes and their modifiers for.
      Returns:
      The current ItemBuilder instance for method chaining.
    • removeAttributeModifier

      public ItemBuilder removeAttributeModifier(@NotNull @NotNull org.bukkit.attribute.Attribute attribute, @NotNull @NotNull org.bukkit.attribute.AttributeModifier modifier)
      Remove a specific Attribute and AttributeModifier. AttributeModifiers are matched according to their UUID.
      Parameters:
      attribute - The Attribute to remove the modifier from.
      modifier - The specific AttributeModifier to remove.
      Returns:
      The current ItemBuilder instance for method chaining.
    • getItemMeta

      @NotNull public @NotNull org.bukkit.inventory.meta.ItemMeta getItemMeta()