All Implemented Interfaces:
Sizeable

public class ToggleGUIButton extends GUIButton
GUIButton which toggles between on and off
  • Constructor Details

    • ToggleGUIButton

      protected ToggleGUIButton(GUI gui, int cooldown, org.bukkit.Sound sound, String permission, boolean toggled, Supplier<org.bukkit.inventory.ItemStack> enabledItem, Supplier<org.bukkit.inventory.ItemStack> disabledItem, ToggleConsumer onToggle)
      Creates a new ToggleGUIButton
      Parameters:
      gui - The GUI
      permission - The permission required to toggle
      toggled - The default value of the toggled-state
      cooldown - The cooldown of the Button
      sound - The sound played when pressing this button
      enabledItem - Used to get the item which is displayed when the button is enabled
      disabledItem - Used to get the item which is displayed when the button is disabled
      onToggle - Executed when the button is toggled
  • Method Details

    • onClick

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

      public void toggle(ClickData clickData)
      Toggles the state of the Button
      Parameters:
      clickData - The clickData of the action
    • getEnabledItem

      protected org.bukkit.inventory.ItemStack getEnabledItem()
      Returns:
      The Item for the enabled-state
    • getDisabledItem

      protected org.bukkit.inventory.ItemStack getDisabledItem()
      Returns:
      The Item for the disabled-state
    • onToggle

      protected void onToggle(ClickData clickData, boolean toggled)
      Gets called when the Button gets toggled
      Parameters:
      clickData - The clickData of the action
      toggled - The current state