Class Item

java.lang.Object
dev.crafty.core.items.Item
All Implemented Interfaces:
org.bukkit.event.Listener

public abstract class Item extends Object implements org.bukkit.event.Listener
Abstract base class for custom items in the CraftyCore plugin. Handles item loading, crafting recipe registration, and action handling.
Since:
1.0.26
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.bukkit.NamespacedKey
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Item(String id, CraftyPlugin plugin)
    Constructs a new custom item.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.ItemStack
    Returns the ItemStack representing this custom item.
    void
    onInteract(org.bukkit.event.player.PlayerInteractEvent event)
     
    protected void
    registerAction(String actionId, BiConsumer<org.bukkit.event.player.PlayerInteractEvent,org.bukkit.inventory.ItemStack> action)
    Registers a custom action for this item.
    protected abstract void
     

    Methods inherited from class java.lang.Object

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

    • ITEM_KEY

      public static final org.bukkit.NamespacedKey ITEM_KEY
  • Constructor Details

    • Item

      public Item(String id, CraftyPlugin plugin)
      Constructs a new custom item.
      Parameters:
      id - The unique identifier for this item.
      plugin - The plugin instance.
  • Method Details

    • registerAction

      protected void registerAction(String actionId, BiConsumer<org.bukkit.event.player.PlayerInteractEvent,org.bukkit.inventory.ItemStack> action)
      Registers a custom action for this item.
      Parameters:
      actionId - The action identifier.
      action - The action logic as a BiConsumer.
    • registerActions

      protected abstract void registerActions()
    • onInteract

      public void onInteract(org.bukkit.event.player.PlayerInteractEvent event)
    • getItem

      public org.bukkit.inventory.ItemStack getItem()
      Returns the ItemStack representing this custom item. Applies metadata if necessary.
      Returns:
      The ItemStack for this item.
      Throws:
      IllegalStateException - if the item is null or AIR.