XaGui Docs
Examples

Multi Page GUI

Creating a multi-page GUI with 6 rows and 2 pages

public class ExamplePages {
 
    public static GuiMenu createGui() {
 
        // We will create gui with 2 pages, all pages will have same amount of rows
        GuiMenu gui = Seasons.xagui.createMenu("&bExample", 3, 2);
 
        // This will fill border for all pages by default
        gui.fillBorder();
        // But you can also fill border for specific page, but you need to add second parameter which is ItemStack
        //gui.fillBorder(1, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
 
        // We can add close buttons to all pages
        gui.addCloseButtonAllPages();
 
        // Now we can set paper in slot 4 of first page
        gui.setSlot(0, 4, new GuiButton(Material.PAPER).setName("&b&lPage: 1"));
 
        // Now we can set oak sign in slot 4 of second page
        gui.setSlot(1, 4, new GuiButton(Material.OAK_SIGN).setName("&6&lPage: 2"));
 
        // Setting the next and previous page buttons
        gui.setSlot(0, 26, new GuiButton(Material.ARROW).setName("&fNext page").withListener((event) -> {
            try {
                gui.switchPage(gui.getCurrentPageIndex()+1, (Player) event.getWhoClicked());
            } catch (PageOutOfBoundException e) {
                throw new RuntimeException(e);
            }
        }));
 
        gui.setSlot(1, 18, new GuiButton(Material.ARROW).setName("&fPrevious page").withListener((event) -> {
            try {
                gui.switchPage(gui.getCurrentPageIndex()-1, (Player) event.getWhoClicked());
            } catch (PageOutOfBoundException e) {
                throw new RuntimeException(e);
            }
        }));
 
        // Now we will set some items on the first page
        gui.setSlot(0, 10, Material.DIAMOND_SWORD);
        gui.setSlot(0, 11, Material.DIAMOND_PICKAXE);
        gui.setSlot(0, 12, Material.DIAMOND_AXE);
        gui.setSlot(0, 13, Material.DIAMOND_SHOVEL);
 
        // And some items on the second page
        gui.setSlot(1, 10, Material.DIAMOND_HELMET);
        gui.setSlot(1, 11, Material.DIAMOND_CHESTPLATE);
        gui.setSlot(1, 12, Material.DIAMOND_LEGGINGS);
        gui.setSlot(1, 13, Material.DIAMOND_BOOTS);
 
        // We can also set a listener for page switch
        gui.setOnPageSwitch((event) -> {
            event.getPlayer().sendMessage("Switched page: " + (event.getOldPage()) + " -> " + event.getPage());
        });
 
        return gui;
    }
}

Opening a single page GUI

ExamplePages.createGui().open(player);

This is the result afterwards:

On this page