Class SimpleButton

java.lang.Object
io.github.projectunified.craftux.simple.SimpleButton
All Implemented Interfaces:
Button

public class SimpleButton extends Object implements Button
A simple implementation of Button that sets an item and action for an ActionItem. The item can be a static value or computed per player, and the action handles click events.

Example usage:


 // Static item and action
 SimpleButton button = new SimpleButton(new ItemStack(Material.DIAMOND), event -> System.out.println("Clicked"));

 // Dynamic item based on player
 SimpleButton dynamicButton = new SimpleButton(
     uuid -> new ItemStack(Material.EMERALD, getPlayerLevel(uuid)),
     event -> System.out.println("Dynamic button clicked")
 );
 
  • Constructor Details

    • SimpleButton

      public SimpleButton(@NotNull @NotNull Function<@NotNull UUID,@Nullable Object> itemFunction, @NotNull @NotNull Consumer<@NotNull Object> consumer)
      Create a new simple button
      Parameters:
      itemFunction - the item function
      consumer - the consumer
    • SimpleButton

      public SimpleButton(@Nullable @Nullable Object item, @NotNull @NotNull Consumer<@NotNull Object> consumer)
      Create a new button
      Parameters:
      item - the item
      consumer - the consumer
    • SimpleButton

      public SimpleButton(@NotNull @NotNull Consumer<@NotNull Object> consumer)
      Create a new button with a null item
      Parameters:
      consumer - the consumer
    • SimpleButton

      public SimpleButton(@NotNull @NotNull Function<@NotNull UUID,@Nullable Object> itemFunction)
      Create a new button
      Parameters:
      itemFunction - the item function
    • SimpleButton

      public SimpleButton(@Nullable @Nullable Object item)
      Create a new button
      Parameters:
      item - the item
  • Method Details

    • apply

      public boolean apply(@NotNull @NotNull UUID uuid, @NotNull @NotNull ActionItem actionItem)
      Description copied from interface: Button
      Apply actions to the action item
      Specified by:
      apply in interface Button
      Parameters:
      uuid - the uuid of the player
      actionItem - the action item
      Returns:
      true if any action was applied. Can return false in a conditional case (e.g. predicate button)