Package dev.crafty.core.items
Class Item
java.lang.Object
dev.crafty.core.items.Item
- All Implemented Interfaces:
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.ItemStack
getItem()
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
-
Field Details
-
ITEM_KEY
public static final org.bukkit.NamespacedKey ITEM_KEY
-
-
Constructor Details
-
Item
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.
-