ποΈPagination
Here you will find all the methods that are in the Pagination class.
How do I get the pagination?
Call
InventoryContents#pagination()
. The return value is the pagination.
Pagination pagination = contents.pagination();
Define elements per page
To define the number of items you use the method
Pagination#setItemsPerPage(value)
If you do not define anything the default value is 1.
Pagination pagination = contents.pagination();
pagination.setItemsPerPage(21);
//In this example we allow 21 elements per page.
Add elements
We have two ways to add items: Pagination#setItems, Pagination#addItem.
setItems (List)
Pagination pagination = contents.pagination();
pagination.setItemsPerPage(21);
pagination.setItems(Arrays.asList(
IntelligentItem.empty(new ItemStack(Material.MAGMA_CREAM)),
IntelligentItem.empty(new ItemStack(Material.TNT)),
IntelligentItem.empty(new ItemStack(Material.DIAMOND_PICKAXE)),
IntelligentItem.empty(new ItemStack(Material.CHAINMAIL_BOOTS)),
IntelligentItem.empty(new ItemStack(Material.FIREWORK_CHARGE)),
IntelligentItem.empty(new ItemStack(Material.FLINT)),
IntelligentItem.empty(new ItemStack(Material.FLINT_AND_STEEL))));
setItems (Array)
Pagination pagination = contents.pagination();
pagination.setItemsPerPage(21);
IntelligentItem[] items = new IntelligentItem[6];
items[0] = IntelligentItem.empty(new ItemStack(Material.MAGMA_CREAM));
items[1] = IntelligentItem.empty(new ItemStack(Material.TNT));
items[2] = IntelligentItem.empty(new ItemStack(Material.DIAMOND_PICKAXE));
items[3] = IntelligentItem.empty(new ItemStack(Material.CHAINMAIL_BOOTS));
items[4] = IntelligentItem.empty(new ItemStack(Material.FIREWORK_CHARGE));
items[5] = IntelligentItem.empty(new ItemStack(Material.FLINT));
pagination.setItems(items);
addItem
Pagination pagination = contents.pagination();
pagination.setItemsPerPage(21);
for (int i = 0; i < 5; i++) {
pagination.addItem(IntelligentItem.empty(new ItemStack(Material.MAGMA_CREAM)));
}
Define SlotIterator
The SlotIterator is needed so that you can decide where the pagination should start placing items.
Furthermore you can decide the type (Horizontal or Vertical)
Furthermore you can decide if the items should be overwritten if there is already an item in this slot.
You can also decide whether certain slots should be ignored.
For example, it might look like this:
pagination.iterator(SlotIterator.builder()
.startPosition(10)
.type(SlotIterator.SlotIteratorType.HORIZONTAL)
.blackList(10)
.override()
.build());
What exactly the methods do and what else there is, you can find in the class SlotIterator.
Method overview
newInstance
Creates a new pagination object based on the old pagination object. The data will be copied.
page
Returns the current page. You are on page 1? You get the value 1. Alternatively, you can specify your own page.
lastPage
Returns the last possible page. If you have a static page it returns this. Otherwise it calculates the last possible page based on the items in the pagination.
inventory
Returns the RyseInventory object.
isLast
A boolean method to know if you are currently on the last page.
isFirst
A boolean method to know if you are on the first page.
next
Increases the current number of pages by 1.
previous
Decreases the current number of pages by 1. Throws an exception if you are on the first page and there is no previous page.
setItems
Defines the items within the pagination. A list or an array is accepted as a paramater.
addItem
Adds a single element to the pagination.
iterator
Defines a SlotIterator. This SlotIterator is responsible for the positions of the items.
setItemsPerPage
Defines how many items are allowed on a page.
Last updated