Class PaginatedMenu<T>

java.lang.Object
com.github.pinont.singularitylib.api.ui.Menu
com.github.pinont.singularitylib.api.ui.PaginatedMenu<T>
Type Parameters:
T - the element type

public class PaginatedMenu<T> extends Menu
A paginated inventory menu over a list of items of type T.

Renders pageSize entries per page into the given content slots, with automatic Prev/Next buttons and a page indicator. This is the foundation for every list-style view (e.g. DevTool v2's plugin lists, world lists, player lists).

  • Constructor Details

    • PaginatedMenu

      public PaginatedMenu(org.bukkit.plugin.Plugin plugin, String title, int size, int pageSize, int[] contentSlots, List<T> items, Function<T, org.bukkit.inventory.ItemStack> itemRenderer, BiConsumer<org.bukkit.entity.Player, T> onClick)
      Parameters:
      plugin - the owning plugin
      title - menu title
      size - inventory size (multiple of 9)
      pageSize - entries per page
      contentSlots - which slots hold content (e.g. slots 9..35)
      items - the full item list
      itemRenderer - maps an element to its ItemStack
      onClick - invoked when a content item is clicked
  • Method Details

    • updateItems

      protected void updateItems(List<T> items, Function<T, org.bukkit.inventory.ItemStack> renderer, BiConsumer<org.bukkit.entity.Player, T> click)
      Re-points the data this menu pages over (used by subclasses that re-render, e.g. a config editor whose key set changes after edits).
    • showPage

      public void showPage(org.bukkit.entity.Player player, int targetPage)
      Jumps to a specific page and re-renders the inventory for the player.
    • getPage

      public int getPage()
    • getMaxPage

      public int getMaxPage()
    • show

      public void show(org.bukkit.entity.Player player)
      Description copied from class: Menu
      Shows this menu to the specified player.
      Overrides:
      show in class Menu
      Parameters:
      player - the player to show the menu to
    • addExtraBottomRowInto

      protected void addExtraBottomRowInto(List<Button> buttons)
      Hook: subclasses add bottom-row buttons here (they are merged before rendering). Default no-op.