Home›Java›Mods›Better Menus API
Better Menus API
ModsJava

Better Menus API

Java mod listed for Minecraft 1.19. Downloads from the MC Java Mods app on Android.

⬇ Download on Spigot
INTRODUCTION

This library will allow you to build menus in a clear and easy way.

This library includes:
To see examples of all of these: https://github.com/JaimeTruman/Bukkit-better-menus

SETUP
Code (XML):
<repositories>
    <repository>
        <id>jitpack.io </id>
        <url>https://jitpack.io </url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.github.JaimeTruman </groupId>
        <artifactId>Bukkit-better-menus </artifactId>
        <version>1.4.0 </version>
    </dependency>
</dependencies>
Code (Java):
public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable ( ) {
        BukkitBetterMenus. setPlugin ( this ) ;
        BukkitBetterMenus. registerEventListeners ( this, Bukkit. getPluginManager ( ) ) ;
        BukkitBetterMenus. setInstanceProvider ( /*Optional if you have dependency injection library*/ ) ;
    }
}
Simple example
Every menu will have to extend Menu. The menu generic parameter is the state that the Menu can have, this is optional. A menu will have to implement:
Code (Java):
public class SimpleMenu extends Menu <Transaction > {
    @Override
    public int [ ] [ ] items ( ) {
        return new int [ ] [ ] {
                { 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                { 1, 0, 2, 0, 0, 0, 0, 9, 1 },
                { 1, 1, 1, 1, 1, 1, 1, 1, 1 }
        } ;
    }

    @Override
    public MenuConfiguration configuration ( ) {
        return MenuConfiguration. builder ( )
                . title (DARK_RED + "" + BOLD + "Simple menu" )
                . fixedItems ( ) //Players cannot take items
                . staticMenu ( ) //Only one instance of inventory will be created
                . item ( 1, Material. BLACK_STAINED_GLASS_PANE )
                . item ( 2, buildItemTransaction ( ) )
                . item ( 9, buildItemClose ( ), (player, event ) -> player. closeInventory ( ) )
                . onClose (event -> event. getPlayer ( ). sendMessage ( "You have closed the inventory" ) )
                . build ( ) ;
    }
 
    private ItemStack buildItemTransaction ( ) {
        return ItemBuilder. of (Material. PAPER )
                . title (GOLD + "" + BOLD + "Transaction" )
                . lore ( Arrays. asList (
                            GOLD + "Payer: " + getState ( ). payerName,
                            GOLD + "Payee: " + getState ( ). payeeName,
                            GOLD + "money: " + GREEN + getState ( ). money + "$"
                ) )
                . build ( ) ;
    }

    private ItemStack buildItemClose ( ) {
        return ItemBuilder. of (Material. BARRIER )
                . title (ChatColor. BOLD + "" + ChatColor. GOLD + "CLOSE" )
                . build ( ) ;
    }
}

public class Transaction {
    public String payerName ;
    public String payeeName ;
    public double money ;
}
result.png

To open the menu:
Code (Java):
    public void open (Player player ) {
        MenuService menuService = BukkitBetterMenus. MENU_SERVICE ;
        Transaction transactionState = /**/ ;
 
        //A menu can have a state represented by Menu<class of state>
        menuService. open (player, new SimpleMenu ( ), transactionState ) ;
 
        //If you have dependency injection library. It will inject the dependencies of the constructor
        menuService. open (player, SimpleMenu. class, transactionState ) ;
    }
To see pagination, synchronization etc you can find them at: https://github.com/JaimeTruman/Bukkit-better-menus

Plugin details

Read from the plugin's own plugin.yml.

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Better Menus API is a free Minecraft Java mod. Compatible with Minecraft 1.19. Downloaded 66 times (via Spigot). Download it and open it directly in the game.

Explore more