GUI's
The API provides a simple way to create GUI's.
Create a GUI
There are two ways to create and open a GUI. The first way is to create a new GUI
object and then open it. The second way is to use the Player.gui()
method.
GUI.java
// This is an example to create a GUI
GUI gui = new GUI(GUIType.FIVTY_FOUR, component("Test"), gui -> {
// This adds a page to the GUI
gui.page(0, page -> {
// This adds an item to the GUI
page.item(0, new ItemStack(Material.DIAMOND));
});
});
// This opens the GUI
gui.open(player);
// OR
player.openGUI(gui);
Or you can use the Player.gui()
method:
onClose
The onClose
method is called when the GUI is closed. This method is called
when the GUI is closed by the player or when the GUI is closed by the server.
It returns a GUICloseEvent.