Your first GUI with one widget. - worldOneo/GUI-API GitHub Wiki

Create a GUI

To create a GUI can simple create a new instance of 'GUI':

GUI gui = new GUI();

Now you cann edit the settings of this GUI:

gui
  .setSize(27) //3 rows
  .setGUITitle("My First GUI!"); //The title of the GUI

Create a button

Some widgets are already included to this API. Lets add a Button!

Button button = new Button(this::clickEvent); //a button takes a Consumer<InventoryClickEvent> as constructor parameter.

Lets define our clickEvent

public void clickEvent(InventoryClickEvent e){
  e.getWhoClicked().sendMessage("You clicked the button!");
}

Lets customize the button a little.

button
  .setSlot(13) //Without setting the slot the button will not be shown!
  .setMaterial(Material.PAPER) //Set the material of the button
  .setTitle("Click me!"); //Set the name of the Button

Finish everything up!

Now we can add this button to your GUI.

button.addToGUI(gui); //gui#addWidget(widget) is also possible but this is recommended

And finally we open the gui for the Player:

gui.open(player);

Done!

You just finished your first GUI!