Class MenuItemConfig
java.lang.Object
net.joseplay.allianceutils.api.menu.MenuItemConfig
Represents a configurable menu item for use in custom inventory menus.
This class encapsulates the properties of a menu item, such as its slot, display name,
lore, material, and click action, allowing for reusable and dynamic menu creation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder class for creating MenuItemConfig instances in a fluent and readable way. -
Constructor Summary
ConstructorsConstructorDescriptionMenuItemConfig(int slot, String displayName, List<String> lore, org.bukkit.Material material, Consumer<org.bukkit.event.inventory.InventoryClickEvent> clickAction) Constructs a new MenuItemConfig with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.inventory.ItemStackCreates an ItemStack for this menu item, applying the configured display name, lore, and material.intgetSlot()Gets the inventory slot where this item should be placed.voidhandleClick(org.bukkit.event.inventory.InventoryClickEvent event) Handles a click event for this menu item by executing the configured click action.
-
Constructor Details
-
MenuItemConfig
public MenuItemConfig(int slot, String displayName, List<String> lore, org.bukkit.Material material, Consumer<org.bukkit.event.inventory.InventoryClickEvent> clickAction) Constructs a new MenuItemConfig with the specified properties.- Parameters:
slot- The inventory slot where the item will be placed.displayName- The display name of the item, with color codes.lore- The lore (description) lines of the item, with color codes.material- The Material type of the item.clickAction- The action to perform when the item is clicked, or null if no action.
-
-
Method Details
-
getSlot
public int getSlot()Gets the inventory slot where this item should be placed.- Returns:
- The slot number.
-
createItem
public org.bukkit.inventory.ItemStack createItem()Creates an ItemStack for this menu item, applying the configured display name, lore, and material. The display name and lore are processed with allianceFontReplace for proper formatting.- Returns:
- The configured ItemStack ready to be placed in an inventory.
-
handleClick
public void handleClick(org.bukkit.event.inventory.InventoryClickEvent event) Handles a click event for this menu item by executing the configured click action. If no click action is defined, this method does nothing.- Parameters:
event- The InventoryClickEvent triggered by clicking the item.
-