Interface Button

All Superinterfaces:
PerformButton, PermissibleButton, PlaceholderButton, SlotButton
All Known Subinterfaces:
BackButton, HomeButton, InventoryButton, NextButton, NoneButton, PaginateButton, PreviousButton

public interface Button extends PermissibleButton, PlaceholderButton, SlotButton, PerformButton

The Button interface defines methods for creating customizable buttons in zMenu. Buttons are a key feature of zMenu, providing a unified way for plugins to create inventory buttons with shared configurations across the server.

For detailed information on creating a button, refer to the zMenu documentation.

  • Method Summary

    Modifier and Type
    Method
    Description
    buildDisplayName(org.bukkit.entity.Player player)
    Builds the display name for auto-update.
    buildLore(org.bukkit.entity.Player player)
    Builds the lore for auto-update.
    boolean
    Checks if the inventory should be closed when clicking.
    List<fr.maxlego08.menu.api.requirement.Action>
    Returns the list of actions performed on click
    List<fr.maxlego08.menu.api.requirement.Requirement>
    Gets the list of requirements made when clicking.
    org.bukkit.inventory.ItemStack
    getCustomItemStack(org.bukkit.entity.Player player)
    Returns the ItemStack that will be used in the inventory with a player in parameter.
    List<fr.maxlego08.menu.api.requirement.data.ActionPlayerData>
    Gets the action player data.
    fr.maxlego08.menu.MenuItemStack
    Returns the ItemStack that will be displayed.
    Gets the messages that the player will receive by clicking.
    Returns the name of the button.
    Allows to open a link in a message.
     
    Gets the player name.
    int
    getRealSlot(int inventorySize, int page)
    Allows to get the real slot of the button.
    int
    Returns the slot used by the button.
    Gets the sound that will be played when the player clicks.
    fr.maxlego08.menu.api.requirement.Requirement
    Gets the requirement that will be used to display the button.
    boolean
     
    boolean
    Checks if the button has special rendering requirements.
    boolean
    Checks if the button can be clicked.
    boolean
    Checks if the button is permanent.
    boolean
    Checks if the button should be refreshed on click.
    boolean
    Checks if the button needs to be updated.
    boolean
     
    void
    onBackClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, List<Inventory> oldInventories, Inventory toInventory, int slot)
    Performs an action when a back button is clicked.
    void
    onClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot, Placeholders placeholders)
    Called when the player makes a click.
    void
    onDrag(org.bukkit.event.inventory.InventoryDragEvent event, org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventoryDefault)
    Called when the player drags items within the inventory or from their player inventory into the zMenu inventory.
    void
    onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventoryDefault)
    Called when the player clicks an item within the zMenu inventory.
    void
    onInventoryClose(org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory)
    Called when the player closes the inventory.
    void
    onInventoryOpen(org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory)
    Called when the player opens the inventory.
    void
    onLeftClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot)
    Called when the player makes a left click.
    void
    onMiddleClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot)
    Called when the player makes a middle click or a drop key click.
    void
    onRender(org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory)
    Allows buttons that are going to be rendered in multiple slots to be rendered correctly.
    void
    onRightClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot)
    Called when the player makes a right click.
    boolean
    Checks if the button should be updated when someone clicks on the inventory.

    Methods inherited from interface fr.maxlego08.menu.api.button.PlaceholderButton

    getPlaceholders, hasPlaceHolder

    Methods inherited from interface fr.maxlego08.menu.api.button.SlotButton

    getSlots
  • Method Details

    • getName

      String getName()
      Returns the name of the button.
      Returns:
      The name of the button.
    • getItemStack

      fr.maxlego08.menu.MenuItemStack getItemStack()
      Returns the ItemStack that will be displayed.
      Returns:
      The MenuItemStack.
    • getCustomItemStack

      org.bukkit.inventory.ItemStack getCustomItemStack(org.bukkit.entity.Player player)
      Returns the ItemStack that will be used in the inventory with a player in parameter.
      Parameters:
      player - The player who opens the inventory.
      Returns:
      The ItemStack.
    • getSlot

      int getSlot()
      Returns the slot used by the button.
      Returns:
      The slot.
    • isClickable

      boolean isClickable()
      Checks if the button can be clicked.
      Returns:
      True if the button is clickable, false otherwise.
    • isPermanent

      boolean isPermanent()
      Checks if the button is permanent. A permanent button will always be present in the inventory, regardless of the page.
      Returns:
      True if the button is permanent, false otherwise.
    • hasSpecialRender

      boolean hasSpecialRender()
      Checks if the button has special rendering requirements.
      Returns:
      True if the button has special rendering, false otherwise.
    • onRender

      void onRender(org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory)
      Allows buttons that are going to be rendered in multiple slots to be rendered correctly.
      Parameters:
      player - The player.
      inventory - The inventory object containing all the information of the current inventory.
    • onClick

      void onClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot, Placeholders placeholders)
      Called when the player makes a click.
      Parameters:
      player - The player who performs the click.
      event - The event that will be called.
      inventory - The inventory where the button comes from.
      slot - The current slot.
    • onRightClick

      void onRightClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot)
      Called when the player makes a right click.
      Parameters:
      player - The player who performs the click.
      event - The event that will be called.
      inventory - The inventory where the button comes from.
    • onLeftClick

      void onLeftClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot)
      Called when the player makes a left click.
      Parameters:
      player - The player who performs the click.
      event - The event that will be called.
      inventory - The inventory where the button comes from.
    • onMiddleClick

      void onMiddleClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, int slot)
      Called when the player makes a middle click or a drop key click.
      Parameters:
      player - The player who performs the click.
      event - The event that will be called.
      inventory - The inventory where the button comes from.
    • onInventoryOpen

      void onInventoryOpen(org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory)
      Called when the player opens the inventory.
      Parameters:
      player - The player.
      inventory - The inventory.
    • onInventoryClose

      void onInventoryClose(org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory)
      Called when the player closes the inventory.
      Parameters:
      player - The player.
      inventory - The inventory.
    • getRealSlot

      int getRealSlot(int inventorySize, int page)
      Allows to get the real slot of the button.
      Parameters:
      inventorySize - The size of the inventory.
      page - The current page.
      Returns:
      The real slot.
    • closeInventory

      boolean closeInventory()
      Checks if the inventory should be closed when clicking.
      Returns:
      True if the inventory should be closed, false otherwise.
    • getMessages

      List<String> getMessages()
      Gets the messages that the player will receive by clicking.
      Returns:
      The list of messages.
    • getSound

      SoundOption getSound()
      Gets the sound that will be played when the player clicks.
      Returns:
      The SoundOption.
    • getPlayerHead

      String getPlayerHead()
      Gets the player name.
      Returns:
      The player name.
    • getOpenLink

      OpenLink getOpenLink()
      Allows to open a link in a message.
      Returns:
      The OpenLink.
    • isUpdated

      boolean isUpdated()
      Checks if the button needs to be updated.
      Returns:
      True if the button needs to be updated, false otherwise.
    • isRefreshOnClick

      boolean isRefreshOnClick()
      Checks if the button should be refreshed on click.
      Returns:
      True if the button should be refreshed on click, false otherwise.
    • getData

      List<fr.maxlego08.menu.api.requirement.data.ActionPlayerData> getData()
      Gets the action player data.
      Returns:
      The list of ActionPlayerData.
    • updateOnClick

      boolean updateOnClick()
      Checks if the button should be updated when someone clicks on the inventory.
      Returns:
      True if the button should be updated, false otherwise.
    • buildDisplayName

      String buildDisplayName(org.bukkit.entity.Player player)
      Builds the display name for auto-update.
      Parameters:
      player - The player.
      Returns:
      The display name.
    • buildLore

      List<String> buildLore(org.bukkit.entity.Player player)
      Builds the lore for auto-update.
      Parameters:
      player - The player.
      Returns:
      The lore.
    • onBackClick

      void onBackClick(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryClickEvent event, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventory, List<Inventory> oldInventories, Inventory toInventory, int slot)
      Performs an action when a back button is clicked.
      Parameters:
      player - The player.
      event - The inventory click event.
      inventory - The current inventory.
      oldInventories - The list of old inventories.
      toInventory - The inventory to open.
      slot - The current slot.
    • getClickRequirements

      List<fr.maxlego08.menu.api.requirement.Requirement> getClickRequirements()
      Gets the list of requirements made when clicking.
      Returns:
      The list of Requirement.
    • getViewRequirement

      fr.maxlego08.menu.api.requirement.Requirement getViewRequirement()
      Gets the requirement that will be used to display the button.
      Returns:
      The Requirement.
    • getActions

      List<fr.maxlego08.menu.api.requirement.Action> getActions()
      Returns the list of actions performed on click
      Returns:
      actions
    • onDrag

      void onDrag(org.bukkit.event.inventory.InventoryDragEvent event, org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventoryDefault)
      Called when the player drags items within the inventory or from their player inventory into the zMenu inventory. This method allows for custom drag behavior to be implemented, providing flexibility in how items can be moved around within an inventory and how these actions interact with the overall functionality of the menu. Implementations can use this method to prevent unwanted item movements, to trigger specific actions when certain items are dragged to specific slots, or to manage the addition or removal of items in custom ways that align with the menu's logic and requirements.
      Parameters:
      event - The inventory drag event that occurred, containing details about the drag action.
      player - The player who performed the drag action.
      inventoryDefault - The zMenu inventory where the drag action occurred, providing context for the action and allowing for inventory-specific handling.
    • onInventoryClick

      void onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player, fr.maxlego08.menu.inventory.inventories.InventoryDefault inventoryDefault)
      Called when the player clicks an item within the zMenu inventory. This method is a general handler for all inventory click events, offering a centralized way to manage interactions within the inventory. It can be used to implement custom click behavior on a global scale, regardless of the specific button or slot clicked.
      Parameters:
      event - The inventory click event that occurred, including details such as the click type and the slot that was clicked.
      player - The player who performed the click action.
      inventoryDefault - The zMenu inventory where the click action occurred, providing the context needed to appropriately respond to the interaction.
    • isUseCache

      boolean isUseCache()
    • getOptions

      List<ButtonOption> getOptions()
    • hasCustomRender

      boolean hasCustomRender()