Class ItemAction
java.lang.Object
net.joseplay.allianceutils.api.menu.ItemAction
Represents an item associated with a click action in a menu system.
This class binds an ItemStack to a Consumer that will be
executed when the item is interacted with in an inventory.
ItemAction action = new ItemAction(item, event -> {
event.setCancelled(true);
// handle click
});
Notes:
- The action is executed with the
InventoryClickEvent - No null validation is performed
- The ItemStack is stored by reference (not cloned)
-
Constructor Summary
ConstructorsConstructorDescriptionItemAction(org.bukkit.inventory.ItemStack itemStack, Consumer<org.bukkit.event.inventory.InventoryClickEvent> action) Creates a new ItemAction. -
Method Summary
Modifier and TypeMethodDescriptionConsumer<org.bukkit.event.inventory.InventoryClickEvent> Returns the click action.org.bukkit.inventory.ItemStackReturns the associated item.
-
Constructor Details
-
ItemAction
public ItemAction(org.bukkit.inventory.ItemStack itemStack, Consumer<org.bukkit.event.inventory.InventoryClickEvent> action) Creates a new ItemAction.- Parameters:
itemStack- the item to associate with the actionaction- the logic to execute on click
-
-
Method Details
-
getItemStack
public org.bukkit.inventory.ItemStack getItemStack()Returns the associated item.- Returns:
- item stack
-
getAction
Returns the click action.- Returns:
- consumer handling the click event
-