Class PaginationPanel

java.lang.Object
redempt.redlib.inventorygui.PaginationPanel

public class PaginationPanel extends Object
A panel in an InventoryGUI which can be used to paginate items and buttons
  • Constructor Details

    • PaginationPanel

      public PaginationPanel(InventoryGUI gui)
      Constructs a PaginationPanel to work on a given InventoryGUI
      Parameters:
      gui - The InventoryGUI to paginate
    • PaginationPanel

      public PaginationPanel(InventoryGUI gui, org.bukkit.inventory.ItemStack fillerItem)
      Constructs a PaginationPanel to work on a given InventoryGUI
      Parameters:
      gui - The InventoryGUI to paginate
      fillerItem - The item to use for the background
  • Method Details

    • setOnUpdate

      public void setOnUpdate(Runnable onUpdate)
      Sets a task to be run whenever the page updates, can be used to update a page indicator or similar
      Parameters:
      onUpdate - The task to be run on update
    • addPagedButton

      public void addPagedButton(ItemButton button)
      Adds a paged button to the panel
      Parameters:
      button - The button to add
    • addPagedItem

      public void addPagedItem(org.bukkit.inventory.ItemStack item)
      Adds a paged item to the panel
      Parameters:
      item - The item to add
    • addPagedButtons

      public void addPagedButtons(Iterable<ItemButton> buttons)
      Adds multiple buttons to the paged panel
      Parameters:
      buttons - The buttons to add
    • addPagedItems

      public void addPagedItems(Iterable<org.bukkit.inventory.ItemStack> items)
      Adds multiple items to the paged panel
      Parameters:
      items - The items to add
    • removePagedItem

      public void removePagedItem(org.bukkit.inventory.ItemStack item)
      Removes an item from the paged panel.
      Parameters:
      item - The item to remove
    • removePagedButton

      public void removePagedButton(ItemButton button)
      Removes a button from the paged panel.
      Parameters:
      button - The button to remove
    • removePagedItems

      public void removePagedItems(Iterable<org.bukkit.inventory.ItemStack> items)
      Removes multiple items from the paged panel
      Parameters:
      items - The items to remove
    • removePagedButtons

      public void removePagedButtons(Iterable<ItemButton> buttons)
      Removes multiple buttons from the paged panel
      Parameters:
      buttons - The buttons to remove
    • getPage

      public int getPage()
      Returns:
      The page this panel is currently on
    • getPageSize

      public int getPageSize()
      Returns:
      The max number of elements displayed on each page
    • getMaxPage

      public int getMaxPage()
      Returns:
      The maximum page number of this panel with the current number of elements
    • addSlot

      public void addSlot(int slot)
      Adds a slot which will be used to display elements
      Parameters:
      slot - The slot to add
    • addSlots

      public void addSlots(int start, int end)
      Adds a range of slots which will be used to display elements
      Parameters:
      start - The start index of slots to add, inclusive
      end - The end index of slots to add, exclusive
    • addSlots

      public void addSlots(int x1, int y1, int x2, int y2)
      Adds a rectangular area of slots which will be used to display elements
      Parameters:
      x1 - The starting X of slots to add, inclusive
      y1 - The starting Y of slots to add, inclusive
      x2 - The ending X of slots to add, exclusive
      y2 - The ending Y of slots to add, exclusive
    • removeSlot

      public void removeSlot(int slot)
      Removes a slot which will be used to display elements
      Parameters:
      slot - The slot to remove
    • removeSlots

      public void removeSlots(int start, int end)
      Removes a range of slots which will be used to display elements
      Parameters:
      start - The start index of slots to remove, inclusive
      end - The end index of slots to remove, exclusive
    • removeSlots

      public void removeSlots(int x1, int y1, int x2, int y2)
      Removes a rectangular area of slots which will be used to display elements
      Parameters:
      x1 - The starting X of slots to remove, inclusive
      y1 - The starting Y of slots to remove, inclusive
      x2 - The ending X of slots to remove, exclusive
      y2 - The ending Y of slots to remove, exclusive
    • updatePage

      public void updatePage()
      Updates the elements displayed on the current page
    • setPage

      public void setPage(int page)
      Sets the page of this panel
      Parameters:
      page - The page to set
    • clear

      public void clear()
      Removes all items and buttons from the panel
    • getItems

      public List<org.bukkit.inventory.ItemStack> getItems()
      Returns:
      All ItemStacks added to this panel
    • getButtons

      public List<ItemButton> getButtons()
      Returns:
      All ItemButtons added to this panel
    • nextPage

      public void nextPage()
      Navigates to the next page, if there is one
    • prevPage

      public void prevPage()
      Navigates to the previous page, if there is one
    • setFillerItem

      public void setFillerItem(org.bukkit.inventory.ItemStack item)
      Sets the filler item
    • getFillerItem

      public org.bukkit.inventory.ItemStack getFillerItem()
      Gets the filler item