Class ListMask

java.lang.Object
io.github.projectunified.craftux.mask.MultiMask<Mask>
io.github.projectunified.craftux.mask.ListMask
All Implemented Interfaces:
Element, Mask

public class ListMask extends MultiMask<Mask>
A mask that applies one of several child masks, cycling through them. Can optionally remember the current mask index per player UUID.

Example usage:


 ListMask listMask = new ListMask();
 listMask.add(
     new SingleMask(Position.of(0, 0), new SimpleButton(new ItemStack(Material.IRON_SWORD))),
     new SingleMask(Position.of(0, 0), new SimpleButton(new ItemStack(Material.BOW))),
     new SingleMask(Position.of(0, 0), new SimpleButton(new ItemStack(Material.SHIELD)))
 );
 listMask.setKeepCurrentIndex(true); // Remember selection per player
 Map<Position, Consumer<ActionItem>> actions = listMask.apply(playerUUID);
 
  • Constructor Details

    • ListMask

      public ListMask()
  • Method Details

    • isKeepCurrentIndex

      public boolean isKeepCurrentIndex()
      Should the mask keep the current index for the unique id?
      Returns:
      true if it should
    • setKeepCurrentIndex

      public void setKeepCurrentIndex(boolean keepCurrentIndex)
      Should the mask keep the current index for the unique id?
      Parameters:
      keepCurrentIndex - true if it should
    • removeCurrentIndex

      public void removeCurrentIndex(UUID uuid)
      Remove the current index for the unique id
      Parameters:
      uuid - the unique id
    • apply

      @Nullable public @Nullable Map<Position,Consumer<ActionItem>> apply(@NotNull @NotNull UUID uuid)
      Description copied from interface: Mask
      Get a map of positions to action item consumers
      Parameters:
      uuid - the uuid of the player
      Returns:
      the map, or null if no items should be displayed. Can return null in a conditional case (e.g. predicate mask)
    • 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
      Overrides:
      stop in class MultiMask<Mask>