-
Notifications
You must be signed in to change notification settings - Fork 9
Menus
Mariusz Matyszczak edited this page Mar 25, 2023
·
2 revisions
The Menu
class is a key component of our library, designed to simplify the process of creating menus in the game. It provides a flexible and intuitive interface for developers to create custom menus. Supporting "paged-menus", populating of buttons, items, and much more.
In comparison to items, the menu API requires a valid manager which is MenuManager
.
You can set it up in your plugin class.
public class YourPlugin extends JavaPlugin {
private MenuManager menuManager;
@Override
public void onEnable() {
this.menuManager = new MenuManager(this); // passing the plugin into the manager
// registering your menus -> (classes that extend the Menu class)
this.menuManager.addMenu(new MyCustomMenu());
this.menuManager.addMenu(new MyShopMenu());
}
@Override
public void onDisable() {
this.menuManager.clearMenus(); // it's a good practice to clear them on disable!
}
}
Basic implementation of Menu
class.
public class DiamondMenu extends Menu {
@Override
public void open(@NotNull Canvas emptyCanvas, @NotNull Player player) {
emptyCanvas
// Title of the menu
.title("Some Empty Menu")
// Rows of the menu
.rows(6)
;
}