📚Full Examples
Here you can find examples of how pagination can be used
Example 1
Description
Code
RyseInventory.builder()
.title("Example 1")
.rows(1)
.provider(new InventoryProvider() {
@Override
public void init(Player player, InventoryContents contents) {
Pagination pagination = contents.pagination();
pagination.setItemsPerPage(7);
pagination.iterator(SlotIterator.builder()
.startPosition(1)
.type(SlotIterator.SlotIteratorType.HORIZONTAL)
.build());
contents.set(0, 0, IntelligentItem.of(new ItemBuilder(Material.ARROW).
amount(pagination.isFirst()
? 1
: pagination.page() - 1)
.displayName(pagination.isFirst()
? "§c§oThis is the first page"
: "§ePage §8⇒ §9" + pagination.newInstance(pagination).previous().page()).build(), event -> {
if (pagination.isFirst()) {
player.sendMessage("§c§oYou are already on the first page.");
return;
}
RyseInventory currentInventory = pagination.inventory();
currentInventory.open(player, pagination.previous().page());
}));
for (int i = 0; i < 13; i++) {
pagination.addItem(IntelligentItem.empty(new ItemStack(Material.MAGMA_CREAM)));
}
int page = pagination.newInstance(pagination).next().page();
contents.set(0, 8, IntelligentItem.of(new ItemBuilder(Material.ARROW)
.amount((pagination.isLast() ? 1 : page))
.displayName(!pagination.isLast()
? "§ePage §8⇒ §9" + page :
"§c§oThis is the last page").build(), event -> {
if (pagination.isLast()) {
player.sendMessage("§c§oYou are already on the last page.");
return;
}
RyseInventory currentInventory = pagination.inventory();
currentInventory.open(player, pagination.next().page());
}));
}
})
.build(this)
.openAll();Preview
Example 2
Last updated