Class CustomItem.Builder

java.lang.Object
com.github.imdabigboss.easydatapack.api.items.CustomItem.Builder
Direct Known Subclasses:
CustomHatItem.Builder, CustomToolItem.Builder
Enclosing class:
CustomItem

public static class CustomItem.Builder extends Object
  • Field Details

    • customModelData

      protected final int customModelData
    • namespaceKey

      protected final String namespaceKey
    • name

      protected final String name
    • baseMaterial

      protected final org.bukkit.Material baseMaterial
    • unbreakable

      protected boolean unbreakable
    • hideFlags

      protected boolean hideFlags
    • newItem

      protected boolean newItem
    • itemUseEvent

      protected Consumer<org.bukkit.event.player.PlayerInteractEvent> itemUseEvent
    • eventListener

      protected Class<? extends org.bukkit.event.Listener> eventListener
    • spacingBeforeLore

      protected boolean spacingBeforeLore
    • lore

      protected String[] lore
    • attributeModifiers

      protected Map<org.bukkit.attribute.Attribute,​List<org.bukkit.attribute.AttributeModifier>> attributeModifiers
    • enchantments

      protected Map<org.bukkit.enchantments.Enchantment,​Integer> enchantments
    • allowedEnchantments

      protected List<org.bukkit.enchantments.Enchantment> allowedEnchantments
    • forbiddenEnchantments

      protected List<org.bukkit.enchantments.Enchantment> forbiddenEnchantments
  • Constructor Details

    • Builder

      public Builder(int customModelData, String namespaceKey, String name, org.bukkit.Material baseMaterial)
      Creates a new item builder.
      Parameters:
      customModelData - the custom model data of the item
      namespaceKey - the namespace key of the item
      name - the name of the item
      baseMaterial - the base material of the item
  • Method Details

    • unbreakable

      public @NonNull CustomItem.Builder unbreakable(boolean unbreakable)
      Sets if the item is unbreakable.
      Parameters:
      unbreakable - if the item is unbreakable
      Returns:
      the builder
    • hideFlags

      public @NonNull CustomItem.Builder hideFlags(boolean hideFlags)
      Sets if the item hides flags.
      Parameters:
      hideFlags - if the item hides flags
      Returns:
      the builder
    • newItem

      public @NonNull CustomItem.Builder newItem(boolean newItem)
      Sets if the item is a new item or if it is an extension of an existing item.
      Parameters:
      newItem - if the item is a new item
      Returns:
      the builder
    • itemUseEvent

      public @NonNull CustomItem.Builder itemUseEvent(@Nullable @Nullable Consumer<org.bukkit.event.player.PlayerInteractEvent> itemUseEvent)
      Sets the event listener of the item.
      Parameters:
      itemUseEvent - the event listener of the item
      Returns:
      the builder
    • eventListener

      public @NonNull CustomItem.Builder eventListener(@Nullable @Nullable Class<? extends org.bukkit.event.Listener> eventListener)
      Sets the event listener of the item.
      Parameters:
      eventListener - the event listener of the item
      Returns:
      the builder
    • lore

      public @NonNull CustomItem.Builder lore(boolean spacingBeforeLore, String... lore)
      Sets the item lore.
      Parameters:
      spacingBeforeLore - if there should be spacing before the lore
      lore - the lore
      Returns:
      the builder
    • lore

      public @NonNull CustomItem.Builder lore(@Nullable @Nullable String... lore)
      Sets the item lore.
      Parameters:
      lore - the lore
      Returns:
      the builder
    • attributeModifier

      public @NonNull CustomItem.Builder attributeModifier(@NonNull org.bukkit.attribute.Attribute attribute, @NonNull org.bukkit.attribute.AttributeModifier attributeModifier)
      Adds an attribute modifier to the item.
      Parameters:
      attribute - the attribute
      attributeModifier - the attribute modifier
      Returns:
      the builder
    • enchantment

      public @NonNull CustomItem.Builder enchantment(@NonNull org.bukkit.enchantments.Enchantment enchantment, int level)
      Adds an enchantment to the item.
      Parameters:
      enchantment - the enchantment
      level - the level
      Returns:
      the builder
    • allowedEnchantment

      public @NonNull CustomItem.Builder allowedEnchantment(@NonNull org.bukkit.enchantments.Enchantment... enchantments) throws CustomItemException
      Adds an allowed enchantment to the item, this can be used if the base material doesn't allow the enchantment by default.
      Parameters:
      enchantments - the enchantments
      Returns:
      the builder
      Throws:
      CustomItemException
    • forbiddenEnchantment

      public @NonNull CustomItem.Builder forbiddenEnchantment(@NonNull org.bukkit.enchantments.Enchantment... enchantments) throws CustomItemException
      Adds a forbidden enchantment to the item, this can be used if the base material allows the enchantment by default.
      Parameters:
      enchantments - the enchantments
      Returns:
      the builder
      Throws:
      CustomItemException
    • build

      public @NonNull CustomItem build()
      Builds the item.
      Returns:
      the item