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

public class CustomItem extends Object
This class represents a custom item.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    This class represents the information about an attribute modifier.
    static class 
     
    static class 
    This class represents the information about an enchantment.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.bukkit.inventory.ItemStack
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    CustomItem​(int customModelData, @NonNull String namespaceKey, @NonNull String name, @NonNull org.bukkit.Material baseMaterial, boolean unbreakable, boolean hideFlags, boolean newItem, @Nullable Class<? extends org.bukkit.event.Listener> eventListener, @Nullable Consumer<org.bukkit.event.player.PlayerInteractEvent> itemUseEvent, boolean spacingBeforeLore, @Nullable String[] lore, @NonNull Map<org.bukkit.attribute.Attribute,​List<org.bukkit.attribute.AttributeModifier>> attributeModifiers, @NonNull Map<org.bukkit.enchantments.Enchantment,​Integer> enchantments, @NonNull List<org.bukkit.enchantments.Enchantment> allowedEnchantments, @NonNull List<org.bukkit.enchantments.Enchantment> forbiddenEnchantments)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull net.kyori.adventure.util.TriState
    canEnchant​(@NonNull org.bukkit.enchantments.Enchantment enchantment)
     
    @Nullable org.bukkit.enchantments.Enchantment[]
    Gets a list of enchantments that can be applied to the item, this can be used if the base material doesn't allow the enchantment by default.
    Gets the item's attribute modifiers.
    @NonNull org.bukkit.Material
    Gets the base material of the item.
    int
    Gets the custom model data of the item.
    Gets the item's enchantments.
    @Nullable Class<? extends org.bukkit.event.Listener>
    Gets the event listener of the item.
    @Nullable org.bukkit.enchantments.Enchantment[]
    Gets a list of enchantments that can't be applied to the item, this can be used if the base material allows the enchantment by default.
    @NonNull org.bukkit.inventory.ItemStack
    Gets the item stack of the item.
    @Nullable Consumer<org.bukkit.event.player.PlayerInteractEvent>
    Gets the event that is fired when the item is used.
    @Nullable String[]
    Gets the item's lore.
    @NonNull String
    Gets the name of the item.
    @NonNull org.bukkit.NamespacedKey
    Gets the namespaced key of the item.
    @NonNull String
    Gets the namespace key of the item.
    boolean
    Gets if the item hides flags.
    boolean
    Gets if the item is a new item or if it is an extension of an existing item.
    boolean
    Gets if the item is unbreakable.

    Methods inherited from class java.lang.Object

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

    • itemStack

      protected org.bukkit.inventory.ItemStack itemStack
  • Constructor Details

    • CustomItem

      protected CustomItem(int customModelData, @NonNull String namespaceKey, @NonNull String name, @NonNull org.bukkit.Material baseMaterial, boolean unbreakable, boolean hideFlags, boolean newItem, @Nullable @Nullable Class<? extends org.bukkit.event.Listener> eventListener, @Nullable @Nullable Consumer<org.bukkit.event.player.PlayerInteractEvent> itemUseEvent, boolean spacingBeforeLore, @Nullable @Nullable String[] lore, @NonNull Map<org.bukkit.attribute.Attribute,​List<org.bukkit.attribute.AttributeModifier>> attributeModifiers, @NonNull Map<org.bukkit.enchantments.Enchantment,​Integer> enchantments, @NonNull List<org.bukkit.enchantments.Enchantment> allowedEnchantments, @NonNull List<org.bukkit.enchantments.Enchantment> forbiddenEnchantments)
  • Method Details

    • getCustomModelData

      public int getCustomModelData()
      Gets the custom model data of the item.
      Returns:
      the custom model data of the item
    • getNamespaceKey

      public @NonNull String getNamespaceKey()
      Gets the namespace key of the item.
      Returns:
      the namespace key of the item
    • getNamespacedKey

      public @NonNull org.bukkit.NamespacedKey getNamespacedKey()
      Gets the namespaced key of the item.
      Returns:
      the namespaced key of the item
    • getName

      public @NonNull String getName()
      Gets the name of the item.
      Returns:
      the name of the item
    • getBaseMaterial

      public @NonNull org.bukkit.Material getBaseMaterial()
      Gets the base material of the item.
      Returns:
      the base material of the item
    • isUnbreakable

      public boolean isUnbreakable()
      Gets if the item is unbreakable.
      Returns:
      if the item is unbreakable
    • isHideFlags

      public boolean isHideFlags()
      Gets if the item hides flags.
      Returns:
      if the item hides flags
    • isNewItem

      public boolean isNewItem()
      Gets if the item is a new item or if it is an extension of an existing item.
      Returns:
      if the item is a new item
    • getEventListener

      @Nullable public @Nullable Class<? extends org.bukkit.event.Listener> getEventListener()
      Gets the event listener of the item.
      Returns:
      the event listener of the item
    • getItemUseEvent

      @Nullable public @Nullable Consumer<org.bukkit.event.player.PlayerInteractEvent> getItemUseEvent()
      Gets the event that is fired when the item is used.
      Returns:
      the event that is fired when the item is used
    • getLore

      @Nullable public @Nullable String[] getLore()
      Gets the item's lore.
      Returns:
      the item's lore
    • getAttributeModifiers

      public @NonNull CustomItem.AttributeInformation[] getAttributeModifiers()
      Gets the item's attribute modifiers.
      Returns:
      the item's attribute modifiers
    • getEnchantments

      public @NonNull CustomItem.EnchantmentInformation[] getEnchantments()
      Gets the item's enchantments.
      Returns:
      the item's enchantments
    • getAllowedEnchantments

      @Nullable public @Nullable org.bukkit.enchantments.Enchantment[] getAllowedEnchantments()
      Gets a list of enchantments that can be applied to the item, this can be used if the base material doesn't allow the enchantment by default.
      Returns:
      a list of enchantments that can be applied to the item
    • getForbiddenEnchantments

      @Nullable public @Nullable org.bukkit.enchantments.Enchantment[] getForbiddenEnchantments()
      Gets a list of enchantments that can't be applied to the item, this can be used if the base material allows the enchantment by default.
      Returns:
      a list of enchantments that can't be applied to the item
    • canEnchant

      public @NonNull net.kyori.adventure.util.TriState canEnchant(@NonNull org.bukkit.enchantments.Enchantment enchantment)
    • getItemStack

      public @NonNull org.bukkit.inventory.ItemStack getItemStack()
      Gets the item stack of the item.
      Returns:
      the item stack of the item