GUI Features
After the basics of a GUI there is a lot more useful features you can use.

Common features

The following are the common features in all GUIs.

Filler

The GUI filler allows you to fill in the GUI in many ways, for example, completely filling or filling the bottom or top of the GUI. You can get the filler by doing GUI#getFiller.
Setting you fill item will fill the slots in your GUI that doesn't contain a GUI item.
1
// Single fill item
2
gui.getFiller().fill(ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE)).asGuiItem());
3
4
// Multiple fill items
5
gui.getFiller().fill(Arrays.asList(ItemBuilder.from(Material.BLACK_STAINED_GLASS_PANE)).asGuiItem(), ItemBuilder.from(Material.WHITE_STAINED_GLASS_PANE)).asGuiItem()));
Copied!
Just like any other item these items can also have a click action, but they'll be the same for all the slots it is filled.

Set default click action

You can also set a default click action, which will be applied to every single slot in the GUI. For example if you call event.setCancelled(true) as your default action, you no longer need to cancel it for every single item.
1
gui.setDefaultClickAction(event -> {
2
// Handle your default action here
3
});
Copied!

Set close GUI action

This will display the action you set when ever the GUI is closed. The event passed down for this action is the InventoryCloseEvent.
1
gui.setCloseGuiAction(event -> {
2
// Handle your close action
3
});
Copied!

Set open GUI action

This will display the action you set when ever the GUI is open . The event passed down for this action is the InventoryOpenEvent.
1
gui.setOpenGuiAction(event -> {
2
// Handle your open action
3
});
Copied!

Slot actions

If you want to add a click action to a specif slot without needing to have to specify the item in the slot, you can simple use the setSlotAction. It also supports both rows and columns and slots.
1
// With slot
2
gui.addSlotAction(slot, event -> {
3
// Handle your open action
4
});
5
6
// With rows and collumns
7
gui.addSlotAction(row, col, event -> {
8
// Handle your open action
9
});
Copied!

Update

The update method will update the entire GUI except the title, due to how inventories work.
1
gui.update();
Copied!

Update title

This will also update the title but you need to pass the new title down. This feature has not been tested enough.
1
gui.updateTitle(Component.text("New Title"));
Copied!

Update Item

This is the preferable way of making updates in your GUI, for example an item that keeps refreshing, etc. This is recommended over the other ones as it'll simply change one item instead of the whole GUI. It also supports both rows and columns and slots.
1
// Using slots
2
gui.updateItem(slot, new ItemStack(Material.STONE));
3
4
// Using rows and collumns
5
gui.updateItem(row, col, new ItemStack(Material.STONE));
Copied!

Item Builder

Triumph-GUI already comes with a built in ItemBuilder to make it easier for you to create custom items.
Last modified 5mo ago