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

  • 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
    • removePageItem

      public void removePageItem(@NotNull @NotNull GuiItem item)
      Removes a given GuiItem from the page.
      Parameters:
      item - The GuiItem to remove.
    • removePageItem

      public void removePageItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Removes a given ItemStack from the page.
      Parameters:
      item - The ItemStack to remove.
    • 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

      @NotNull public @NotNull BaseGui updateTitle(@NotNull @NotNull net.kyori.adventure.text.Component title)
      Overrides BaseGui.updateTitle(Component) 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
    • getCurrentPageItems

      @NotNull public @NotNull Map<@NotNull Integer,@NotNull GuiItem> getCurrentPageItems()
      Gets an immutable Map with all the current pages items
      Returns:
      The Map with all the currentPage
    • getPageItems

      @NotNull public @NotNull List<@NotNull 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
      Returns:
      False if there is no next page.
    • previous

      public boolean previous()
      Goes to the previous page if possible
      Returns:
      False if there is no previous page.
    • getPagesNum

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

      public void clearPageItems(boolean update)
      Clears all previously added page items
    • clearPageItems

      public void clearPageItems()
    • setPageNum

      public void setPageNum(int pageNum)
      Sets the page number
      Parameters:
      pageNum - Sets the current page to be the specified number