ModsJava
Better Menus API
Java mod listed for Minecraft 1.19. Downloads from the MC Java Mods app on Android.
⬇ Download on SpigotINTRODUCTION
This library will allow you to build menus in a clear and easy way.
This library includes:
SETUP
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:
To open the menu:
To see pagination, synchronization etc you can find them at:
https://github.com/JaimeTruman/Bukkit-better-menus
This library will allow you to build menus in a clear and easy way.
This library includes:
- Pagination
- Menu synchronization
- Built in: confirmation & number selector type menus
- Timers, async tasks
- Communication via messaging between 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>
<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*/ ) ;
}
}
@Override
public void onEnable ( ) {
BukkitBetterMenus. setPlugin ( this ) ;
BukkitBetterMenus. registerEventListeners ( this, Bukkit. getPluginManager ( ) ) ;
BukkitBetterMenus. setInstanceProvider ( /*Optional if you have dependency injection library*/ ) ;
}
}
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:
- public int[][] items() Represents the outlay of the menu. It will contain a number which will map to an item.
- public MenuConfiguration configuration() Returns the menu configuration. It will also include the mapping of the numbers to items
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 ;
}
@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 ;
}
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 ) ;
}
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 ) ;
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft version listed: 1.19
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
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.