XaGui Docs
XaGUI

Pages and pagination

Create, resize, navigate, and decorate multi-page menus.

GuiMenu menu = xaGui.createMenu("&8Catalog", 6, 3);

Pages use zero-based indexes in every method. Valid indexes above are 0, 1, and 2.

menu.setSlot(0, 10, Material.DIAMOND);
menu.setSlot(1, 10, Material.EMERALD);
menu.setSlot(2, 10, Material.GOLD_INGOT);

menu.getCurrentPageIndex(); // zero-based
menu.getCurrentPage();      // one-based display number
menu.getMaxPages();         // allocated count

Automatic paginator

menu.fillBorder();
menu.addCloseButtonAllPages();
menu.addPaginator();
menu.setPageSwitchSound(Sound.ITEM_BOOK_PAGE_TURN);
menu.open(player);

Previous and next controls appear in the bottom row at columns 4 and 6 (zero-based offsets 3 and 5). The close button uses the center column.

Shared controls

GuiButton back = new GuiButton(Material.OAK_DOOR)
        .setName("&eBack")
        .withListener(event -> openMainMenu(event.getPlayer()));

menu.setAllPageSlot(45, back);

Or put a button on page 0 and make its slot sticky; it is copied when another page opens:

menu.setSlot(0, 45, back);
menu.stickSlot(45);

Dynamic page counts

int itemsPerPage = 28;
int pages = Math.max(1, (int) Math.ceil(entries.size() / (double) itemsPerPage));
menu.setTotalPages(pages);

Call setTotalPages before borders, all-page controls, and data slots. switchPage(index, player) throws PageOutOfBoundException for an invalid index; the automatic paginator only creates valid navigation buttons.

On this page