v3 PagedKamiMenu - Jake-Moore/KamiCommon GitHub Wiki
See V4 Getting Started for more information.
The gui/menu feature is only available in spigot-jar
.
PagedKamiMenu
is the KamiCommon solution to paged menus.
It wraps KamiMenu
while providing page-specific methods and callbacks.
This feature is only available in the spigot-jar
module of KamiCommon.
// From an existing KamiMenu
KamiMenu yourMenu = new KamiMenu("&cMenu Title", 6);
PagedKamiMenu paged = yourMenu.wrapAsPaged();
// Other constructors are available to pre-load paged items and slot configurations
PagedKamiMenu paged2 = new PagedKamiMenu(yourMenu);
// Add items to be paginated (they will appear in the order they are added)
MenuItem item = paged.addPagedItem(new ItemStack(Material.DIAMOND));
// Set typical click callbacks
item.setMenuClick((plr, clickType) -> {
// click callback for this specific paged item, in
});
// Or listen to a click with the page info in the callback
item.setMenuClick((MenuClickPage) (plr, clickType, page) -> {
// click callback with the page index included
});
// To change where paged items are placed, use
paged.setPageSlots(List.of(0, 1, 2));
// To change the next/previous ItemStacks, use MenuItem access via
paged.getNextPageIcon().getIBuilders() // add, remove, etc
paged.getPrevPageIcon().setItemSlot(...) // change the slot
// Slots can also be modified via util methods
paged.setPrevIconSlot(50);
paged.setNextIconSlot(52);
// Optionally exclude page numbers from being added to the title
paged.setAppendTitleWithPage(false);
It is essential that you open the PagedKamiMenu
and not the KamiMenu
directly.
// Open the menu for a player
paged.openMenu(player, 0); // player, page-index