Class SimpleButtonMask
java.lang.Object
io.github.projectunified.craftux.simple.SimpleButtonMask
A simple mask that associates buttons with multiple positions in the GUI grid.
Allows placing the same button in multiple slots or different buttons in various positions.
Example usage:
SimpleButtonMask mask = new SimpleButtonMask();
mask.setButton(Position.of(0, 0), new SimpleButton(new ItemStack(Material.GRASS_BLOCK)));
mask.setButton(Position.of(1, 1), new SimpleButton(new ItemStack(Material.STONE)));
mask.setButton(Position.of(0, 1), new SimpleButton(new ItemStack(Material.GRASS_BLOCK))); // Same button in multiple positions
Map<Position, Consumer<ActionItem>> actions = mask.apply(playerUUID);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull Map<Position, Consumer<ActionItem>> Get a map of positions to action item consumersGet the button-to-slot mapvoidinit()Initialize the element.voidSet the buttonvoidsetButton(Collection<Position> positions, @NotNull Button button) Set the buttonvoidstop()Stop the element.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.projectunified.craftux.common.Mask
getActionMap
-
Constructor Details
-
SimpleButtonMask
public SimpleButtonMask()
-
-
Method Details
-
setButton
Set the button- Parameters:
position- the positionbutton- the button
-
setButton
Set the button- Parameters:
positions- the collection of positionbutton- the button
-
getButtonSlotMap
Get the button-to-slot map- Returns:
- the button-to-slot map
-
init
public void init()Description copied from interface:ElementInitialize the element. Should be called before adding to the GUI. -
stop
public void stop()Description copied from interface:ElementStop the element. Should be called after removing from the GUI. -
apply
Description copied from interface:MaskGet a map of positions to action item consumers
-