Class MenuItemConfig

java.lang.Object
net.joseplay.allianceutils.api.menu.MenuItemConfig

public class MenuItemConfig extends Object
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 Classes
    Modifier and Type
    Class
    Description
    static class 
    A builder class for creating MenuItemConfig instances in a fluent and readable way.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.inventory.ItemStack
    Creates an ItemStack for this menu item, applying the configured display name, lore, and material.
    int
    Gets the inventory slot where this item should be placed.
    void
    handleClick(org.bukkit.event.inventory.InventoryClickEvent event)
    Handles a click event for this menu item by executing the configured click action.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.