PaginatedGUI

If your GUI requires more space than the maximum size allows, this type of inventory is for you! Creating one is simple - you may either instantiate a PaginatedGUI object or extend the class, but with the added step of calling the #draw method. The last two slots are reserved for navigation.

Option 1: Object

Quick and easy, this method is ideal for infrequent use of your GUI:

// Create the object with title and size
PaginatedGUI pg = new PagiantedGUI(new GUI("Hidden Veggie", Rows.SIX));
// Show a cute fruit and a hidden veggie
pg.setItem(0, new Item(Material.APPLE));
pg.setItem(69, new Item(Material.CARROT);
// Render visible slots
pg.draw();
// Open the inventory for a Player
pg.openInventory(player);

If your resource supports versions of Minecraft both before and after 1.13, you'll need to be careful with Materials. Passing as a String instead ("APPLE") may give you better results with some items, but we recommend using a library like XMaterial.

Note that nothing special happens when your Player clicks an Item. To add a response for those slots, see the Response page.

Option 2: Extended Class

This method is preferred if you intend to reuse your GUI frequently and/or show it to multiple players at once:

public class MyCustomGUI extends PaginatedGUI {
    public MyCustomGUI() {
        super(new GUI("Hidden Vegetable"), Rows.SIX);
    
        // Show a cute fruit or hidden veggie
        for (int i=0; i<69; i++){
            Item item;
            if (i < 42) {
                item = new Item(Material.APPLE);
            } else {
                item = new Item("CARROT");
                item.setDisplayName("Secret To All");
            }
            setItem(i, item);
        }
        
        // Render visible slots
        draw();
    }
}

// Call #openInventory from another class or listener

Note that nothing special happens when your Player clicks an Item other than the navigation arrows. To add a response for those slots, see the Response page.

If your resource supports versions of Minecraft both before and after 1.13, you'll need to be careful with Materials. Passing as a String instead ("APPLE") may give you better results with some items, but we recommend using a library like XMaterial.

As a bonus, let's set all unpopulated slots to an Item:

public class MyCustomGUI extends PaginatedGUI {
    public MyCustomGUI() {
        super(new GUI("Hidden Vegetable"), Rows.SIX);
    
        // Show a cute fruit or hidden veggie
        for (int i=0; i<69; i++){
            Item item;
            if (i < 42) {
                item = new Item(Material.APPLE);
            } else {
                item = new Item("CARROT");
                item.setDisplayName("Secret To All");
            }
            setItem(i, item);
        }
        
        // Render visible slots
        draw();
        
        // Set blank slots to pretty filler
        for (int j = 0; j < getGui().getRows().getSlots(); j++) {
            if (getGui().getItemFor(j) == null) {
                setItem(j, "STAINED_GLASS_PANE");
            }
        }
    }
}

// Call #openInventory from another class or listener

Last updated