Class AbstractPagedGui<C>

java.lang.Object
xyz.xenondevs.invui.gui.AbstractGui
xyz.xenondevs.invui.gui.AbstractPagedGui<C>
Type Parameters:
C - The content type.
All Implemented Interfaces:
Gui, GuiParent, PagedGui<C>

public abstract class AbstractPagedGui<C> extends AbstractGui implements PagedGui<C>
A Gui with pages.

Only in very rare circumstances should this class be used directly. Instead, use the static builder or factory functions from the PagedGui interface, such as PagedGui.items(), PagedGui.guis() or, PagedGui.inventories() to create a new PagedGui.

See Also:
  • PagedItemsGuiImpl
  • PagedNestedGuiImpl
  • Field Details

    • content

      protected List<C> content
      The content of the gui, to be displayed on the pages.
    • pages

      protected List<List<SlotElement>> pages
      The baked pages of the gui, containing the content.
  • Constructor Details

    • AbstractPagedGui

      public AbstractPagedGui(int width, int height, boolean infinitePages, int... contentListSlots)
      Creates a new AbstractPagedGui.
      Parameters:
      width - The width of the gui.
      height - The height of the gui.
      infinitePages - Whether the gui has infinite pages.
      contentListSlots - The slots to be used for pages.
    • AbstractPagedGui

      public AbstractPagedGui(int width, int height, boolean infinitePages, Structure structure)
      Creates a new AbstractPagedGui.
      Parameters:
      width - The width of the gui.
      height - The height of the gui.
      infinitePages - Whether the gui has infinite pages.
      structure - The structure of the gui.
  • Method Details

    • goForward

      public void goForward()
      Description copied from interface: PagedGui
      Displays the next page if there is one.
      Specified by:
      goForward in interface PagedGui<C>
    • goBack

      public void goBack()
      Description copied from interface: PagedGui
      Displays the previous page if there is one.
      Specified by:
      goBack in interface PagedGui<C>
    • setPage

      public void setPage(int page)
      Description copied from interface: PagedGui
      Sets the current page of this PagedGui.
      Specified by:
      setPage in interface PagedGui<C>
      Parameters:
      page - The page to set.
    • hasNextPage

      public boolean hasNextPage()
      Description copied from interface: PagedGui
      Checks if there is a next page.
      Specified by:
      hasNextPage in interface PagedGui<C>
      Returns:
      Whether there is a next page.
    • hasPreviousPage

      public boolean hasPreviousPage()
      Description copied from interface: PagedGui
      Checks if there is a previous page.
      Specified by:
      hasPreviousPage in interface PagedGui<C>
      Returns:
      Whether there is a previous page.
    • update

      protected void update()
      Updates the gui, by first correcting the current page and then updating all relevant items.
    • setContent

      public void setContent(@Nullable @Nullable List<C> content)
      Description copied from interface: PagedGui
      Sets the content of this PagedGui for all pages.
      Specified by:
      setContent in interface PagedGui<C>
      Parameters:
      content - The content to set.
    • getPageAmount

      public int getPageAmount()
      Description copied from interface: PagedGui
      Gets the amount of pages this PagedGui has.
      Specified by:
      getPageAmount in interface PagedGui<C>
      Returns:
      The amount of pages this PagedGui has.
    • getCurrentPage

      public int getCurrentPage()
      Description copied from interface: PagedGui
      Gets the current page of this PagedGui as an index.
      Specified by:
      getCurrentPage in interface PagedGui<C>
      Returns:
      Gets the current page of this PagedGui as an index.
    • hasInfinitePages

      public boolean hasInfinitePages()
      Description copied from interface: PagedGui
      Gets if there are infinite pages in this PagedGui.
      Specified by:
      hasInfinitePages in interface PagedGui<C>
      Returns:
      Whether there are infinite pages in this PagedGui.
    • getContentListSlots

      public int[] getContentListSlots()
      Description copied from interface: PagedGui
      Gets the slot indices that are used to display content in this PagedGui.
      Specified by:
      getContentListSlots in interface PagedGui<C>
      Returns:
      The slot indices that are used to display content in this PagedGui.
    • addPageChangeHandler

      public void addPageChangeHandler(@NotNull @NotNull BiConsumer<Integer,Integer> pageChangeHandler)
      Description copied from interface: PagedGui
      Registers a page change handler.
      Specified by:
      addPageChangeHandler in interface PagedGui<C>
      Parameters:
      pageChangeHandler - The handler to register.
    • removePageChangeHandler

      public void removePageChangeHandler(@NotNull @NotNull BiConsumer<Integer,Integer> pageChangeHandler)
      Description copied from interface: PagedGui
      Unregisters a page change handler.
      Specified by:
      removePageChangeHandler in interface PagedGui<C>
      Parameters:
      pageChangeHandler - The handler to unregister.
    • setPageChangeHandlers

      public void setPageChangeHandlers(@Nullable @Nullable List<@NotNull BiConsumer<Integer,Integer>> handlers)
      Description copied from interface: PagedGui
      Replaces the currently registered page change handlers with the given list.
      Specified by:
      setPageChangeHandlers in interface PagedGui<C>
      Parameters:
      handlers - The new page change handlers.
    • getPageChangeHandlers

      @Nullable public @Nullable List<BiConsumer<Integer,Integer>> getPageChangeHandlers()
      Description copied from interface: PagedGui
      Gets the registered page change handlers.
      Specified by:
      getPageChangeHandlers in interface PagedGui<C>
      Returns:
      The registered page change handlers.