Class OutputButton
java.lang.Object
io.github.projectunified.craftux.spigot.button.OutputButton
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanapply(@NotNull UUID uuid, @NotNull ActionItem actionItem) Apply actions to the action item@Nullable org.bukkit.inventory.ItemStackgetOutputItem(@NotNull UUID uuid) Get the output 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 GUIvoidsetOutputItem(@NotNull UUID uuid, @Nullable org.bukkit.inventory.ItemStack itemStack) Set the output item for the unique idvoidstop()Stop the element.
-
Constructor Details
-
OutputButton
public OutputButton()
-
-
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. -
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 iditemStack- 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
-