java.lang.Object
io.github.projectunified.craftux.spigot.button.OutputButton
All Implemented Interfaces:
Button, Element

public class OutputButton extends Object implements Element, Button
A button that stores an output item per player and allows taking it to the cursor when clicked with an empty cursor. Useful for creating output slots where players can retrieve items.

Example usage:


 OutputButton outputButton = new OutputButton();
 outputButton.setOutputItem(playerUUID, new ItemStack(Material.DIAMOND));
 outputButton.setDisplayItemFunction((uuid, item) -> {
     if (item == null) return new ItemStack(Material.AIR);
     return item;
 });
 
  • Constructor Details

    • OutputButton

      public OutputButton()
  • 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)
    • stop

      public void stop()
      Description copied from interface: Element
      Stop the element. Should be called after removing from the GUI.
      Specified by:
      stop in interface Element
    • setOutputItem

      public void setOutputItem(@NotNull @NotNull UUID uuid, @Nullable @Nullable org.bukkit.inventory.ItemStack itemStack)
      Set the output item for the unique id
      Parameters:
      uuid - the unique id
      itemStack - the item, or null to remove the output button
    • getOutputItem

      @Nullable public @Nullable org.bukkit.inventory.ItemStack getOutputItem(@NotNull @NotNull UUID uuid)
      Get the output item for the unique id
      Parameters:
      uuid - the unique id
      Returns:
      the item
    • setDisplayItemFunction

      @Contract("_ -> this") public OutputButton setDisplayItemFunction(@NotNull @NotNull BiFunction<UUID,org.bukkit.inventory.ItemStack,org.bukkit.inventory.ItemStack> displayItemFunction)
      Set the function to display the item on the GUI
      Parameters:
      displayItemFunction - the function
      Returns:
      this instance