> For the complete documentation index, see [llms.txt](https://jpprison.gitbook.io/jpprison-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jpprison.gitbook.io/jpprison-docs/developer-api/api-menus.md).

# API — Menus

#### Opening Internal Menus

void openMainUpgradeMenu(Player player)void openDisenchantMenu(Player player)void openPetsMenu(Player player)

#### Injecting Extra Items Into Existing Menus

void addMainMenuItem(String id, int slot, Function\<Player, ItemStack> itemSupplier, BiConsumer\<Player, InventoryClickEvent> onClick)boolean removeMainMenuItem(String id)void addPetMenuItem(String id, int slot, ...)boolean removePetMenuItem(String id)

```
JPPrisonAPI.addMainMenuItem(
    "myaddon_quests", 8,
    player -> {
        ItemStack item = new ItemStack(Material.BOOK);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("\u00a7e\u00a7lDaily Quests");
        item.setItemMeta(meta);
        return item;
    },
    (player, event) -> {
        player.closeInventory();
        openQuestMenu(player);
    }
);
```

#### Full Custom Menus (CustomMenu)

void registerMenu(CustomMenu menu)boolean unregisterMenu(String menuId)CustomMenu getMenu(String menuId)Collection\<CustomMenu> getRegisteredMenus()boolean openMenu(Player player, String menuId)

```
CustomMenu menu = new CustomMenu("myaddon_stats", "&5&lYour Stats", 27)
    .onOpen((player, menuRef) -> {
        long tokens = JPPrisonAPI.getTokens(player.getUniqueId());
        ItemStack item = new ItemStack(Material.GOLD_INGOT);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("\u00a76Balance: \u00a7e" + tokens);
        item.setItemMeta(meta);
        menuRef.setItem(13, item);
    })
    .setItem(22, closeButton, (p, e) -> p.closeInventory());

JPPrisonAPI.registerMenu(menu);
JPPrisonAPI.openMenu(player, "myaddon_stats");
```

CustomMenu builder: `setTitle`, `setSize`, `setItem(slot, item)`, `setItem(slot, item, onClick)`, `removeItem(slot)`, `onOpen`, `onClose`. Size must be a multiple of 9 between 9 and 54.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://jpprison.gitbook.io/jpprison-docs/developer-api/api-menus.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
