Class MutableButton

java.lang.Object
net.staticstudios.menus.button.MutableButton
All Implemented Interfaces:
Button

public class MutableButton extends Object implements Button
Represents a button which can be modified after its creation
  • Constructor Details

    • MutableButton

      protected MutableButton(org.bukkit.inventory.ItemStack source, Map<Button.Action,List<ButtonAction>> actions)
      Create a new mutable button
      Parameters:
      source - the source item stack
      actions - the actions
  • Method Details

    • setName

      public void setName(String name)
      Set the name of the button
      Parameters:
      name - the name
    • setName

      public void setName(net.kyori.adventure.text.Component name)
      Set the name of the button
      Parameters:
      name - the name
    • editName

      public void editName(@NotNull @NotNull Function<net.kyori.adventure.text.Component,net.kyori.adventure.text.Component> nameEditor)
      Edit the name of the button
      Parameters:
      nameEditor - the name editor
    • editNameAsString

      public void editNameAsString(@NotNull @NotNull Function<String,String> nameEditor)
      Edit the name of the button. Note that this method will serialize the name to a string and then deserialize it back to a component
      Parameters:
      nameEditor - the name editor
    • setDescription

      public void setDescription(List<String> description)
      Set the description of the button
      Parameters:
      description - the description
    • setDescription

      public void setDescription(String... description)
      Set the description of the button
      Parameters:
      description - the description
    • setDescription

      public void setDescription(net.kyori.adventure.text.Component... description)
      Set the description of the button
      Parameters:
      description - the description
    • editDescription

      public void editDescription(@NotNull @NotNull Function<List<net.kyori.adventure.text.Component>,List<net.kyori.adventure.text.Component>> descriptionEditor)
      Edit the description of the button
      Parameters:
      descriptionEditor - the description editor
    • editDescriptionAsStrings

      public void editDescriptionAsStrings(@NotNull @NotNull Function<List<String>,List<String>> descriptionEditor)
      Edit the description of the button. Note that this method will serialize the lore to strings and then deserialize them back to components
      Parameters:
      descriptionEditor - the description editor
    • setCount

      public void setCount(int count)
      Set the count of the button
      Parameters:
      count - the count
    • addAction

      public void addAction(Button.Action action, ButtonAction buttonAction)
      Add an action to the button
      Parameters:
      action - the action (type)
      buttonAction - the action (to run)
    • setActions

      public void setActions(Button.Action action, List<ButtonAction> buttonActions)
      Set the actions of the button
      Parameters:
      action - the action (type)
      buttonActions - the actions (to run)
    • clearActions

      public void clearActions()
      Clear all actions of the button
    • clearActions

      public void clearActions(Button.Action action)
      Clear all actions of the button for a specific action (type)
      Parameters:
      action - the action (type)
    • getItemRepresentation

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getItemRepresentation(MenuViewer viewer, Menu menu)
      Description copied from interface: Button
      Get the item representation of the button. This is the item that will be displayed in the menu.
      Specified by:
      getItemRepresentation in interface Button
      Parameters:
      viewer - the viewer
      menu - the menu
      Returns:
      the item stack
    • invokeActions

      public void invokeActions(@NotNull @NotNull Button.Action action, @NotNull @NotNull Menu menu, @NotNull @NotNull MenuViewer viewer)
      Description copied from interface: Button
      Invoke the actions of the button
      Specified by:
      invokeActions in interface Button
      Parameters:
      action - the action (type)
      menu - the menu
      viewer - the viewer