Class InputButton
java.lang.Object
io.github.projectunified.craftux.spigot.button.InputButton
A button that stores an input item per player and allows swapping it with the cursor item on click.
Useful for creating input slots where players can place items.
Example usage:
InputButton inputButton = new InputButton();
inputButton.setDisplayItemFunction((uuid, item) -> {
if (item == null) return new ItemStack(Material.BARRIER); // Show barrier if empty
return item;
});
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanapply(@NotNull UUID uuid, @NotNull ActionItem actionItem) Apply actions to the action item@Nullable org.bukkit.inventory.ItemStackgetInputItem(@NotNull UUID uuid) Get the input item for the unique idsetDisplayItemFunction(@NotNull BiFunction<UUID, org.bukkit.inventory.ItemStack, org.bukkit.inventory.ItemStack> displayItemFunction) Set the function to display the item on the GUIvoidsetInputItem(@NotNull UUID uuid, @Nullable org.bukkit.inventory.ItemStack itemStack) Set the input item for the unique idvoidstop()Stop the element.
-
Constructor Details
-
InputButton
public InputButton()
-
-
Method Details
-
apply
Description copied from interface:ButtonApply actions to the action item -
stop
public void stop()Description copied from interface:ElementStop the element. Should be called after removing from the GUI. -
setInputItem
public void setInputItem(@NotNull @NotNull UUID uuid, @Nullable @Nullable org.bukkit.inventory.ItemStack itemStack) Set the input item for the unique id- Parameters:
uuid- the unique iditemStack- the item, or null to remove the input item
-
getInputItem
Get the input item for the unique id- Parameters:
uuid- the unique id- Returns:
- the item
-
setDisplayItemFunction
@Contract("_ -> this") public InputButton 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
-