Class PaginatedPane

java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.PaginatedPane

public class PaginatedPane extends Pane
A pane for panes that should be spread out over multiple pages
  • Constructor Details

    • PaginatedPane

      public PaginatedPane(int length, int height, @NotNull @NotNull Pane.Priority priority)
      Creates a new paginated pane
      Parameters:
      length - the length of the pane
      height - the height of the pane
      priority - the priority of the pane
      Since:
      0.12.0
    • PaginatedPane

      public PaginatedPane(int length, int height)
      Creates a new paginated pane
      Parameters:
      length - the length of the pane
      height - the height of the pane
      Since:
      0.12.0
  • Method Details

    • getPage

      public int getPage()
      Returns the current page
      Returns:
      the current page
    • getPages

      public int getPages()
      Returns the amount of pages
      Returns:
      the amount of pages
    • addPage

      public void addPage(@NotNull @NotNull Slot slot, @NotNull @NotNull Pane pane)
      Adds the specified pane to a new page. The new page will be at the index one after the highest indexed page currently in this paginated pane. If this paginated pane has no pages, the index of the newly created page will be zero.
      Parameters:
      slot - the slot of the pane
      pane - the pane to add to a new page
      Since:
      0.10.8
    • addPane

      public void addPane(int page, @NotNull @NotNull Slot slot, @NotNull @NotNull Pane pane)
      Adds a pane to a selected page. If the page does not exist and is exactly one larger than the current highest page index, this method will create a new page with the specified pane. If the page does not exist and is more than one larger than the current highest page index, this method will throw an IllegalArgumentException. If the page is negative, an IllegalArgumentException will also be thrown. If there are currently no pages, only index 0 is valid and will create a new page with the specified pane added to it.

      For example, if the pages 0, 1, ..., n currently exist, then:

      • Indexes < 0 will throw an exception
      • Indexes 0, 1, ..., n will add the pane to the respective page
      • Index n + 1 will create a new page with the specified pane
      • Indexes > n + 1 will throw an exception
      Parameters:
      page - the page to assign the pane to
      slot - the slot of the pane
      pane - the new pane
      Throws:
      IllegalArgumentException - if the page is less than 0 or more than one larger than the current highest page index
    • setPage

      public void setPage(int page)
      Sets the current displayed page. If the specified page does not exist an ArrayIndexOutOfBoundsException is thrown.
      Parameters:
      page - the page
      Throws:
      ArrayIndexOutOfBoundsException - if the page does not exist
    • populateWithItemStacks

      public void populateWithItemStacks(@NotNull @NotNull List<@NotNull ItemStack> items, @NotNull @NotNull Plugin plugin)
      Populates the PaginatedPane based on the provided list by adding new pages until all items can fit. This can be helpful when dealing with lists of unknown size.
      Parameters:
      items - The list to populate the pane with
      plugin - the plugin that will be the owner of the items created
      Since:
      0.10.8
      See Also:
    • populateWithItemStacks

      public void populateWithItemStacks(@NotNull @NotNull List<ItemStack> items)
      Populates the PaginatedPane based on the provided list by adding new pages until all items can fit. This can be helpful when dealing with lists of unknown size.
      Parameters:
      items - The list to populate the pane with
    • populateWithGuiItems

      @Contract("null -> fail") public void populateWithGuiItems(@NotNull @NotNull List<GuiItem> items)
      Populates the PaginatedPane based on the provided list by adding new pages until all items can fit. This can be helpful when dealing with lists of unknown size.
      Parameters:
      items - The list to populate the pane with
    • populateWithNames

      public void populateWithNames(@NotNull @NotNull List<String> displayNames, @Nullable @Nullable Material material, @NotNull @NotNull Plugin plugin)
      This method creates a list of ItemStacks all with the given material and the display names. After that it calls populateWithItemStacks(List) This method also translates the color char & for all names.
      Parameters:
      displayNames - The display names for all the items
      material - The material to use for the ItemStacks
      plugin - the plugin that will be the owner of the created items
      Since:
      0.10.8
      See Also:
    • populateWithNames

      public void populateWithNames(@NotNull @NotNull List<String> displayNames, @Nullable @Nullable Material material)
      This method creates a list of ItemStacks all with the given material and the display names. After that it calls populateWithItemStacks(List) This method also translates the color char & for all names.
      Parameters:
      displayNames - The display names for all the items
      material - The material to use for the ItemStacks
    • display

      @NotNull public @NotNull GuiItemContainer display()
      Description copied from class: Pane
      Returns a GuiItemContainer with all the items that should be displayed of this pane.
      Specified by:
      display in class Pane
      Returns:
      a container containing all the items to be displayed
    • click

      public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull GuiComponent guiComponent, @NotNull @NotNull InventoryClickEvent event, @NotNull @NotNull Slot slot)
      Description copied from class: Pane
      Called whenever there is being clicked on this pane
      Specified by:
      click in class Pane
      Parameters:
      gui - the gui in which was clicked
      guiComponent - the gui component in which this pane resides
      event - the event that occurred while clicking on this item
      slot - the slot that was clicked in
      Returns:
      whether the item was found or not
    • copy

      @NotNull @Contract(pure=true) public @NotNull PaginatedPane copy()
      Description copied from class: Pane
      Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane.
      Overrides:
      copy in class Pane
      Returns:
      a copy of this pane
    • deletePage

      public void deletePage(int page)
      Deletes a page and all its associated panes from this paginated pane. It also decrements the indexes of all pages beyond the specified page by one. For example, given a sequence of pages 0, 1, 2, 3, 4, upon removing page 2, the new sequence of pages will be 0, 1, 2, 3. If the specified page does not exist, then this method will silently do nothing.
      Parameters:
      page - the page to delete
      Since:
      0.10.5
    • getPanes

      @NotNull @Contract(pure=true) public @NotNull Collection<Pane> getPanes()
      Description copied from class: Pane
      Gets all the panes in this panes, including any child panes from other panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)
      Specified by:
      getPanes in class Pane
      Returns:
      all panes
    • getPanes

      @NotNull @Contract(pure=true) public @NotNull Collection<Pane> getPanes(int page)
      Gets all the panes from inside the specified page of this pane. If the specified page is not existent, this method will throw an IllegalArgumentException. If the specified page is existent, but doesn't have any panes, the returned collection will be empty. The returned collection is unmodifiable. The returned collection is not synchronized and no guarantees should be made as to the safety of concurrently accessing the returned collection. If synchronized behaviour should be allowed, the returned collection must be synchronized externally.
      Parameters:
      page - the panes of this page will be returned
      Returns:
      a collection of panes belonging to the specified page
      Throws:
      IllegalArgumentException - if the page does not exist
      Since:
      0.5.13
    • getItems

      @NotNull @Contract(pure=true) public @NotNull Collection<GuiItem> getItems()
      Description copied from class: Pane
      Gets all the items in this pane and all underlying panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)
      Specified by:
      getItems in class Pane
      Returns:
      all items
    • clear

      public void clear()
      Description copied from class: Pane
      Clears the entire pane of any items/panes. Underlying panes will not be cleared.
      Specified by:
      clear in class Pane
    • load

      @NotNull public static @NotNull PaginatedPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin)
      Loads a paginated pane from a given element
      Parameters:
      instance - the instance class
      element - the element
      plugin - the plugin that will be used to create the items
      Returns:
      the paginated pane
      Since:
      0.10.8