Class PlaceholderMask

java.lang.Object
io.github.projectunified.craftux.mask.PlaceholderMask
All Implemented Interfaces:
Element, Mask

public class PlaceholderMask extends Object implements Element, Mask
A mask that allows setting different masks for individual players, with a default mask fallback. Useful for personalized GUI layouts per user.

Example usage:


 PlaceholderMask placeholderMask = new PlaceholderMask();
 placeholderMask.setDefaultMask(new SingleMask(Position.of(0, 0), new SimpleButton(new ItemStack(Material.STONE))));
 placeholderMask.setMask(playerUUID, new SingleMask(Position.of(0, 0), new SimpleButton(new ItemStack(Material.DIAMOND))));
 Map<Position, Consumer<ActionItem>> actions = placeholderMask.apply(playerUUID);
 
  • Field Details

    • userMasks

      protected final Map<UUID,Mask> userMasks
    • defaultMask

      protected Mask defaultMask
  • Constructor Details

    • PlaceholderMask

      public PlaceholderMask()
  • Method Details

    • init

      public void init()
      Description copied from interface: Element
      Initialize the element. Should be called before adding to the GUI.
      Specified by:
      init in interface Element
    • 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
    • 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
      Specified by:
      apply in interface Mask
      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)
    • setMask

      public void setMask(@NotNull @NotNull UUID uuid, @Nullable @Nullable Mask mask)
      Set the mask for the unique id
      Parameters:
      uuid - the unique id
      mask - the mask
    • getMask

      @Nullable public @Nullable Mask getMask(@NotNull @NotNull UUID uuid)
      Get the mask for the unique id
      Parameters:
      uuid - the unique id
      Returns:
      the mask
    • getDefaultMask

      @NotNull public @NotNull Mask getDefaultMask()
      Get the default mask
      Returns:
      the default mask
    • setDefaultMask

      public void setDefaultMask(@NotNull @NotNull Mask defaultMask)
      Set the default mask
      Parameters:
      defaultMask - the default mask
    • getUserMasks

      @NotNull public @NotNull Map<UUID,Mask> getUserMasks()
      Get the user-mask map
      Returns:
      the user-mask map