Class PaginatedGui

java.lang.Object
dev.triumphteam.gui.guis.BaseGui
dev.triumphteam.gui.guis.PaginatedGui
All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
Direct Known Subclasses:
ScrollingGui

public class PaginatedGui
extends BaseGui
GUI that allows you to have multiple pages
  • Constructor Details

    • PaginatedGui

      public PaginatedGui​(int rows, int pageSize, @NotNull @NotNull net.kyori.adventure.text.Component title, @NotNull @NotNull java.util.Set<InteractionModifier> interactionModifiers)
      Main constructor to provide a way to create PaginatedGui, uses Component
      Parameters:
      rows - The amount of rows the GUI should have
      title - The GUI's title using Component
      interactionModifiers - A set containing what InteractionModifier this GUI should have
      Since:
      3.0.0
    • PaginatedGui

      public PaginatedGui​(int rows, int pageSize, @NotNull @NotNull net.kyori.adventure.text.Component title)
      Alternative constructor of the PaginatedGui, uses Component and provides a way to create PaginatedGui that don't use any InteractionModifier
      Parameters:
      rows - The rows the GUI should have
      pageSize - The pageSize
      title - The title using Component
      Since:
      3.0.0
    • PaginatedGui

      public PaginatedGui​(int rows, @NotNull @NotNull net.kyori.adventure.text.Component title)
      Alternative constructor for the PaginatedGui without page size
      Parameters:
      title - The title using Component
      Since:
      3.0.0
    • PaginatedGui

      public PaginatedGui​(@NotNull @NotNull net.kyori.adventure.text.Component title)
      Alternative constructor that only requires title
      Parameters:
      title - The title using Component
      Since:
      3.0.0
    • PaginatedGui

      @Deprecated public PaginatedGui​(int rows, int pageSize, @NotNull @NotNull java.lang.String title)
      Deprecated.
      Old main constructor of the PaginatedGui
      Parameters:
      rows - The rows the GUI should have
      pageSize - The pageSize
      title - The GUI's title
    • PaginatedGui

      @Deprecated public PaginatedGui​(int rows, @NotNull @NotNull java.lang.String title)
      Deprecated.
      Alternative constructor that doesn't require the pageSize to be defined
      Parameters:
      rows - The rows the GUI should have
      title - The GUI's title
    • PaginatedGui

      @Deprecated public PaginatedGui​(@NotNull @NotNull java.lang.String title)
      Deprecated.
      Alternative constructor that only requires title
      Parameters:
      title - The GUI's title
  • Method Details

    • setPageSize

      public BaseGui setPageSize​(int pageSize)
      Sets the page size
      Parameters:
      pageSize - The new page size
      Returns:
      The GUI for easier use when declaring, works like a builder
    • addItem

      public void addItem​(@NotNull @NotNull GuiItem item)
      Adds an GuiItem to the next available slot in the page area
      Parameters:
      item - The GuiItem to add to the page
    • addItem

      public void addItem​(@NotNull @NotNull GuiItem... items)
      Overridden BaseGui.addItem(GuiItem...) to add the items to the page instead
      Overrides:
      addItem in class BaseGui
      Parameters:
      items - Varargs for specifying the GuiItems
    • update

      public void update()
      Overridden BaseGui.update() to use the paginated open
      Overrides:
      update in class BaseGui
    • updatePageItem

      public void updatePageItem​(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Updates the page GuiItem on the slot in the page Can get the slot from InventoryClickEvent.getSlot()
      Parameters:
      slot - The slot of the item to update
      itemStack - The new ItemStack
    • updatePageItem

      public void updatePageItem​(int row, int col, @NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Alternative updatePageItem(int, ItemStack) that uses ROWS and COLUMNS instead
      Parameters:
      row - The row of the slot
      col - The columns of the slot
      itemStack - The new ItemStack
    • updatePageItem

      public void updatePageItem​(int slot, @NotNull @NotNull GuiItem item)
      Alternative updatePageItem(int, ItemStack) that uses GuiItem instead
      Parameters:
      slot - The slot of the item to update
      item - The new ItemStack
    • updatePageItem

      public void updatePageItem​(int row, int col, @NotNull @NotNull GuiItem item)
      Alternative updatePageItem(int, GuiItem) that uses ROWS and COLUMNS instead
      Parameters:
      row - The row of the slot
      col - The columns of the slot
      item - The new GuiItem
    • open

      public void open​(@NotNull @NotNull org.bukkit.entity.HumanEntity player)
      Overrides BaseGui.open(HumanEntity) to use the paginated populator instead
      Overrides:
      open in class BaseGui
      Parameters:
      player - The HumanEntity to open the GUI to
    • open

      public void open​(@NotNull @NotNull org.bukkit.entity.HumanEntity player, int openPage)
      Specific open method for the Paginated GUI Uses populatePage()
      Parameters:
      player - The HumanEntity to open it to
      openPage - The specific page to open at
    • updateTitle

      public BaseGui updateTitle​(@NotNull @NotNull java.lang.String title)
      Overrides BaseGui.updateTitle(String) to use the paginated populator instead Updates the title of the GUI This method may cause LAG if used on a loop
      Overrides:
      updateTitle in class BaseGui
      Parameters:
      title - The title to set
      Returns:
      The GUI for easier use when declaring, works like a builder
    • updateTitle

      public BaseGui updateTitle​(@NotNull @NotNull net.kyori.adventure.text.Component title)
      Description copied from class: BaseGui
      Updates the title of the GUI. I do not recommend using this too often.
      Overrides:
      updateTitle in class BaseGui
      Parameters:
      title - The title to set.
      Returns:
      The GUI for easier use when declaring, works like a builder.
    • getCurrentPageItems

      public java.util.Map<java.lang.Integer,​GuiItem> getCurrentPageItems()
      Gets an immutable Map with all the current pages items
      Returns:
      The Map with all the currentPage
    • getPageItems

      public java.util.List<GuiItem> getPageItems()
      Gets an immutable List with all the page items added to the GUI
      Returns:
      The List with all the pageItems
    • getCurrentPageNum

      public int getCurrentPageNum()
      Gets the current page number
      Returns:
      The current page number
    • getNextPageNum

      public int getNextPageNum()
      Gets the next page number
      Returns:
      The next page number or pageNum if no next is present
    • getPrevPageNum

      public int getPrevPageNum()
      Gets the previous page number
      Returns:
      The previous page number or pageNum if no previous is present
    • next

      public boolean next()
      Goes to the next page
    • nextPage

      @Deprecated public boolean nextPage()
      Deprecated.
      Use next() instead
      Goes to the next page
    • previous

      public boolean previous()
      Goes to the previous page if possible
    • prevPage

      @Deprecated public boolean prevPage()
      Deprecated.
      Use previous() instead
      Goes to the previous page if possible
    • getPagesNum

      public int getPagesNum()
      Gets the number of pages the GUI has
      Returns:
      The pages number