All Implemented Interfaces:
Sizeable
Direct Known Subclasses:
CommandGUIButton, CycleGUIButton, PaginatorGUIButton, SubmitGUIButton, SwitchGUIButton, TeleportGUIButton, ToggleGUIButton

public class GUIButton extends GUIItem
A GUIItem with the ability to get clicked. Various onclick methods can be implemented and overridden. The cooldown is being set for the whole material of the ItemStack.
  • Constructor Details

    • GUIButton

      protected GUIButton(GUI gui, org.bukkit.inventory.ItemStack item, int cooldown, org.bukkit.Sound clickSound, String permission, Consumer<ClickData> onClick, Consumer<ClickData> onShiftClick, Consumer<ClickData> onLeftClick, Consumer<ClickData> onRightClick, Consumer<ClickData> onShiftLeftClick, Consumer<ClickData> onShiftRightClick)
      Creates a new GUIButton
      Parameters:
      gui - The GUI
      item - The ItemStack of the GUIButton
      cooldown - The cooldown after which the button can be clicked again in ticks
      clickSound - The sound the button should make on click. null if silent.
      permission - The permission required to click the button
      onClick - Called when the player clicks a button
      onShiftClick - Called when the player shift-clicks a button
      onLeftClick - Called when the player left-clicks a button
      onRightClick - Called when the player right-clicks a button
      onShiftLeftClick - Called when the player shift-right-clicks a button
      onShiftRightClick - Called when the player shift-left-clicks a button
    • GUIButton

      protected GUIButton(GUI gui, org.bukkit.inventory.ItemStack item, int cooldown, org.bukkit.Sound clickSound, String permission)
      Creates a new GUIButton
      Parameters:
      gui - The GUI
      item - The ItemStack of the GUIButton
      cooldown - The cooldown after which the button can be clicked again in ticks
      clickSound - The sound the button should make on click. null if silent.
      permission - The permission required to click the button
  • Method Details

    • hasPermission

      public boolean hasPermission(org.bukkit.entity.Player player)
      Checks if the player has the permission to click this button
      Parameters:
      player - The player
      Returns:
      true if the player has the permission or the permission is null, false otherwise
    • click

      public void click(org.bukkit.entity.Player player)
      Is called when a player clicks on the Button
      Parameters:
      player - The Player
    • applyCooldown

      public void applyCooldown()
      Applies the cooldown to the Button
    • setCooldown

      public void setCooldown(int cooldown)
      Sets the cooldown after which the Button can be clicked again
      Parameters:
      cooldown - The cooldown in ticks
    • onClick

      public void onClick(ClickData data)
      Is called when the player clicks on the Button no matter how.
      Parameters:
      data - The ClickData
    • onLeftClick

      public void onLeftClick(ClickData data)
      Is called when the player left-clicks the Button without sneaking
      Parameters:
      data - The ClickData
    • onRightClick

      public void onRightClick(ClickData data)
      Is called when the player right-clicks the Button without sneaking
      Parameters:
      data - The ClickData
    • onShiftClick

      public void onShiftClick(ClickData data)
      Is called when the player clicks the Button while sneaking
      Parameters:
      data - The ClickData
    • onShiftLeftClick

      public void onShiftLeftClick(ClickData data)
      Is called when the player left-clicks the Button while sneaking
      Parameters:
      data - The ClickData
    • onShiftRightClick

      public void onShiftRightClick(ClickData data)
      Is called when the player right-clicks the Button while sneaking
      Parameters:
      data - The ClickData
    • onItemClick

      public void onItemClick(ClickData data)
      Description copied from class: GUISection
      Called when a user clicks on an item. Usually after this method one of the add/remove/amount methods is called.
      Overrides:
      onItemClick in class GUIItem
      Parameters:
      data - The clickdata