Interface Pagination

All Known Implementing Classes:
Pagination.Impl

public interface Pagination

Pagination system which lets you switch pages; easily get items in the given page, easily manipulate the pages and check if a page is the first or the last one (isFirst() / isLast()).

You must start by setting the items and the itemsPerPage, then you can manipulate the pages by using the page(int) / first() / previous() / next() / last() methods.

Then, when you need to get all the items of the current page, either use the getPageItems() method, or directly add the items to your inventory with a SlotIterator and the method addToIterator(SlotIterator)

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Adds all the current page items to the given iterator.
    Sets the current page to the first page.
    int
    Gets the current page.
    Gets the items of the current page.
    boolean
    Checks if the current page is the first page.
    boolean
    Checks if the current page is the last page.
    Sets the current page to the last page.
    Sets the current page to the next page, if the current page is already the last page, this do nothing.
    page(int page)
    Sets the current page.
    Sets the current page to the previous page, if the current page is already the first page, this do nothing.
    Sets all the items for this Pagination.
    setItemsPerPage(int itemsPerPage)
    Sets the maximum amount of items per page.
  • Method Details

    • getPageItems

      ClickableItem[] getPageItems()
      Gets the items of the current page.
      This returns an array of the size of the items per page.
      Returns:
      the current page items
    • getPage

      int getPage()
      Gets the current page.
      Returns:
      the current page
    • page

      Pagination page(int page)
      Sets the current page.
      Parameters:
      page - the current page
      Returns:
      this, for chained calls
    • isFirst

      boolean isFirst()
      Checks if the current page is the first page.
      This is equivalent to: page == 0
      Returns:
      true if this page is the first page
    • isLast

      boolean isLast()
      Checks if the current page is the last page.
      This is equivalent to: page == itemsCount / itemsPerPage
      Returns:
      true if this page is the last page
    • first

      Pagination first()
      Sets the current page to the first page.
      This is equivalent to: page(0)
      Returns:
      this, for chained calls
    • previous

      Pagination previous()
      Sets the current page to the previous page, if the current page is already the first page, this do nothing.
      Returns:
      this, for chained calls
    • next

      Pagination next()
      Sets the current page to the next page, if the current page is already the last page, this do nothing.
      Returns:
      this, for chained calls
    • last

      Pagination last()
      Sets the current page to the last page.
      This is equivalent to: page(itemsCount / itemsPerPage)
      Returns:
      this, for chained calls
    • addToIterator

      Pagination addToIterator(SlotIterator iterator)
      Adds all the current page items to the given iterator.
      Parameters:
      iterator - the iterator
      Returns:
      this, for chained calls
    • setItems

      Pagination setItems(ClickableItem... items)
      Sets all the items for this Pagination.
      Parameters:
      items - the items
      Returns:
      this, for chained calls
    • setItemsPerPage

      Pagination setItemsPerPage(int itemsPerPage)
      Sets the maximum amount of items per page.
      Parameters:
      itemsPerPage - the maximum amount of items per page
      Returns:
      this, for chained calls