-
Notifications
You must be signed in to change notification settings - Fork 3
Creating Ordinary Menus
Mazen edited this page Aug 2, 2024
·
13 revisions
Lotus depends mainly on Paper-API and java 17 to operate. make sure you have those before we begin
You must create a Lotus
instance in your onEnable()
Quick example:
public class Test extends JavaPlugin {
private Lotus api;
@Override
public void onEnable() {
api = new Lotus(this, EventPriority.NORMAL);
}
}
In Lotus, menus object MenuView
is not meant to be dealt with when using the API.
You should stick to using a Menu
; it's an interface that defines the information created when opening the menus.
Here's an example:
public class TestMenu implements Menu {
/**
* @param extraData the extra data for the menus (usually empty)
* @param opener the player who is opening this menu
* @return the title for this menu
*/
@Override
public @NotNull MenuTitle createTitle(DataRegistry extraData, Player opener) {
return MenuTitles.createModern("<red>My Title");
}
/**
* @param extraData the extra data for the menus (usually empty)
* @param opener the player who is opening this menu
* @return the capacity/size for this menu
*/
@Override
public @NotNull Capacity createCapacity(DataRegistry extraData, Player opener) {
return Capacity.ofRows(5);
}
/**
* Creates the content for the menu
*
* @param extraData the extra data for the menus (usually empty)
* @param opener the player opening this menu
* @param capacity the capacity set by the user above
* @return the content of the menu to add (this includes items)
*/
@Override
public @NotNull Content createContent(DataRegistry extraData, Player opener, Capacity capacity) {
return Content.builder(capacity)
.setButton(0, Button.clickable(new ItemStack(Material.APPLE),(menu, clickEvent)-> {
opener.sendMessage("You have clicked on an apple !");
}))
.build();
}
}
Call the method Lotus#openMenu
example >>
api.openMenu(player, new TestMenu());
If you want more detailed wiki check out other pages on the right-side of this page and thanks in advance <3