Class PaginatedMask

java.lang.Object
io.github.projectunified.craftux.mask.PaginatedMask
All Implemented Interfaces:
Element, Mask
Direct Known Subclasses:
ButtonPaginatedMask, MaskPaginatedMask, SequencePaginatedMask

public abstract class PaginatedMask extends Object implements Element, Mask
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected final Map<UUID,Integer>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(@NotNull UUID uuid)
    Get a map of positions to action item consumers
    protected int
    getAndSetExactPage(UUID uuid, int page, int pageAmount)
    Get the exact page from the input page and set it if it's not the same
    protected int
    getExactPage(int page, int pageAmount)
    Get the exact page from the input page
    protected abstract @Nullable Map<Position,Consumer<ActionItem>>
    getItemMap(@NotNull UUID uuid, int pageNumber)
    Generate the item map for the unique id
    int
    getPage(@NotNull UUID uuid)
    Get the current page for the unique id
    boolean
    Check if this paginated mask allows cycle page (The first page after the last page)
    void
    nextPage(@NotNull UUID uuid)
    Set the next page for the unique id
    void
    previousPage(@NotNull UUID uuid)
    Set the previous page for the unique id
    void
    setCycle(boolean cycle)
    Set if this paginated mask allows cycle page (The first page after the last page)
    void
    setPage(@NotNull UUID uuid, int page)
    Set the page for the unique id

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.github.projectunified.craftux.common.Element

    init, stop

    Methods inherited from interface io.github.projectunified.craftux.common.Mask

    getActionMap
  • Field Details

    • pageNumberMap

      protected final Map<UUID,Integer> pageNumberMap
    • cycle

      protected boolean cycle
  • Constructor Details

    • PaginatedMask

      public PaginatedMask()
  • Method Details

    • getItemMap

      @Nullable protected abstract @Nullable Map<Position,Consumer<ActionItem>> getItemMap(@NotNull @NotNull UUID uuid, int pageNumber)
      Generate the item map for the unique id
      Parameters:
      uuid - the unique id
      pageNumber - the page number
      Returns:
      the map contains the positions and the buttons
    • getExactPage

      protected int getExactPage(int page, int pageAmount)
      Get the exact page from the input page
      Parameters:
      page - the input page
      pageAmount - the amount of pages
      Returns:
      the exact page
    • getAndSetExactPage

      protected int getAndSetExactPage(UUID uuid, int page, int pageAmount)
      Get the exact page from the input page and set it if it's not the same
      Parameters:
      uuid - the unique id
      page - the input page
      pageAmount - the amount of pages
      Returns:
      the exact page
    • setPage

      public void setPage(@NotNull @NotNull UUID uuid, int page)
      Set the page for the unique id
      Parameters:
      uuid - the unique id
      page - the page
    • getPage

      public int getPage(@NotNull @NotNull UUID uuid)
      Get the current page for the unique id
      Parameters:
      uuid - the unique id
      Returns:
      the page number
    • nextPage

      public void nextPage(@NotNull @NotNull UUID uuid)
      Set the next page for the unique id
      Parameters:
      uuid - the unique id
    • previousPage

      public void previousPage(@NotNull @NotNull UUID uuid)
      Set the previous page for the unique id
      Parameters:
      uuid - the unique id
    • isCycle

      public boolean isCycle()
      Check if this paginated mask allows cycle page (The first page after the last page)
      Returns:
      true if it does
    • setCycle

      public void setCycle(boolean cycle)
      Set if this paginated mask allows cycle page (The first page after the last page)
      Parameters:
      cycle - true if it does
    • 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)