Closed iKstruuh closed 3 years ago
That's a bug. I'm pushing up a fix for that now.
(and 3). You can provide your own custom pagination button builder which is a lambda class you can use to specify exactly how the pagination buttons should be built for either your inventory or all inventories by your plugin. You can either call setDefaultPaginationButtonBuilder
on your plugin's SpiGUI instance to set the default for all inventories created by your plugin or call setPaginationButtonBuilder
on the specific inventory.
The default pagination button builder implementation is here: https://github.com/SamJakob/SpiGUI/blob/master/src/main/java/com/samjakob/spigui/SpiGUI.java#L61
(type, inventory) -> {
switch (type) {
case PREV_BUTTON:
if (inventory.getCurrentPage() > 0) return new SGButton(new ItemBuilder(Material.ARROW)
.name("&a&l\u2190 Previous Page")
.lore(
"&aClick to move back to",
"&apage " + inventory.getCurrentPage() + ".")
.build()
).withListener(event -> {
event.setCancelled(true);
inventory.previousPage(event.getWhoClicked());
});
else return null;
case CURRENT_BUTTON:
return new SGButton(new ItemBuilder(Material.NAME_TAG)
.name("&7&lPage " + (inventory.getCurrentPage() + 1) + " of " + inventory.getMaxPage())
.lore(
"&7You are currently viewing",
"&7page " + (inventory.getCurrentPage() + 1) + "."
).build()
).withListener(event -> event.setCancelled(true));
case NEXT_BUTTON:
if (inventory.getCurrentPage() < inventory.getMaxPage() - 1) return new SGButton(new ItemBuilder(Material.ARROW)
.name("&a&lNext Page \u2192")
.lore(
"&aClick to move forward to",
"&apage " + (inventory.getCurrentPage() + 2) + "."
).build()
).withListener(event -> {
event.setCancelled(true);
inventory.nextPage(event.getWhoClicked());
});
else return null;
case UNASSIGNED:
default:
return null;
}
}
The UNASSIGNED
item is any slot not currently defined, the others are self-explanatory.
At the moment there is no way to change the position of each one as the slot is pre-defined. If you'd like to be able to move the positions of the items, I can update the button builder to include a slot parameter.
@SamJakob It would be great if you add an option to make that the pagination row always appear. My other question is that if there there is a way to set a different pagination botton builder per each inventory and how to do it?
@loquendero The bug fix I pushed (v1.2.2) means that the pagination row will now always appear (as it was supposed to) provided you have pagination on for the inventory (it's on by default).
You can set the pagination button builder per-inventory using setPaginationButtonBuilder
on the specific inventory instance.
@SamJakob yeah i could already do it. I created all the new items in the SGPaginationButtonType class, after created a new SGPaginationButtonBuilder in the SpiGUI class with a getter method and finally used inventory.setPaginationButtonBuilder(getterMethod);
I don't know if that is the most effective way, if it is not the case, please tell me.
Well, thank you very much, now you can close the "ticket".
That should do it for now, although you say you did it in the SpiGUI class? You should be able to do it in your own classes similar to how it's done in the library, though as someone pointed out on the Spigot forum, the lambda approach I've taken at the moment is a little unwieldy so I might replace it with a proper implementation and when I do that I'll add some proper docs to the wiki.
In any case, closing for now, will update if I introduce a better method.
Hi, your API is awesome but I have some questions about the pagination system.
First, only when there are two items created, the pagination row and items are showed, as you can see, but is there a way to make that the row and its items always appear even though there are less than two items?
Second, is there a way to change the slot of the pagination items? (the nametag and arrows).
Thirth and finally, is there a way to add more items to the pagination row? for example glass panels to decorate.
That is all, thank you.