GUI API
Define menus in YAML and open them for players
YAML
menus/main.yml
# plugins/YourPlugin/menus/main.yml
title: "&0Main Menu"
size: 54
items:
close:
material: BARRIER
slot: 53
name: "&cClose"
on_left_click:
- "close"
diamond:
material: DIAMOND
slot: 0
amount: 1
name: "&bDiamond"
lore:
- "Shiny, precious gem"
on_left_click:
- "console give %player% diamond 64"
- "message &aYou received diamonds!"
- "opengui shop"menus/shop.yml
# plugins/YourPlugin/menus/shop.yml
title: "&aShop"
size: 27
items:
back:
material: ARROW
slot: 26
name: "&7Back"
on_left_click:
- "opengui main"Java
MyPlugin.java
import io.github.chi2l3s.nextlib.api.gui.GuiManager;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin {
private GuiManager guiManager;
@Override
public void onEnable() {
guiManager = new GuiManager(this);
// Load all *.yml from /menus
java.io.File menusFolder = new java.io.File(getDataFolder(), "menus");
guiManager.loadFromFolder(menusFolder);
// Simple command to open a GUI by file name (without .yml)
getCommand("menu").setExecutor((sender, cmd, label, args) -> {
if (sender instanceof Player player) {
String id = args.length > 0 ? args[0] : "main"; // main -> main.yml
guiManager.openGui(player, id);
}
return true;
});
}
}Actions
- close — closes the inventory
- command <cmd> — run as player
- console <cmd> — run as console
- message <text> — send colored chat message
- opengui <id> — open another GUI