Class MultiPositionMask

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

public class MultiPositionMask extends MultiMask<Button>
A mask that applies a list of buttons to multiple positions, cycling through buttons if there are more positions than buttons. Useful for repeating patterns across a grid.

Example usage:


 MultiPositionMask mask = new MultiPositionMask(
     uuid -> Arrays.asList(Position.of(0, 0), Position.of(1, 0), Position.of(2, 0))
 );
 mask.add(
     new SimpleButton(new ItemStack(Material.RED_CONCRETE)),
     new SimpleButton(new ItemStack(Material.BLUE_CONCRETE))
 );
 // Positions 0 and 2 get red concrete, position 1 gets blue concrete
 
  • Field Details

  • Constructor Details

    • MultiPositionMask

      public MultiPositionMask(@NotNull @NotNull Function<UUID,List<Position>> maskPositionFunction)
      Create a new mask
      Parameters:
      maskPositionFunction - the mask position function
  • Method Details

    • getMaskPositionFunction

      @NotNull public @NotNull Function<UUID,List<Position>> getMaskPositionFunction()
      Get the mask position function
      Returns:
      the mask position
    • apply

      @NotNull public @NotNull 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)