Registering a GUI - TypicalFin/PluginCore GitHub Wiki

Example of a GUI:

public class MyGui extends Gui {

    public MyGui(JavaPlugin plugin) {
        super(plugin, 27, "My Title");
    }

    @Override
    public void initialize() {
        // Initialize your GUI here. Example:
        final ItemStack apple = new ItemBuilder(Material.APPLE, 16)
                .setDisplayName("&aApple")
                .setLore("&fThis is an apple.")
                .addEnchantment(Enchantment.DURABILITY, 1)
                .addItemFlags(ItemFlag.HIDE_ENCHANTS)
                .build();

        inventory.setItem(0, apple);
    }

    @Override
    public void onInventoryOpen(InventoryOpenEvent event) {
        // Do whatever you want to do.
    }

    @Override
    public void onInventoryClick(InventoryClickEvent event) {
        // Do whatever you want to do.
    }

    @Override
    public void onInventoryClose(InventoryCloseEvent event) {
        // Do whatever you want to do.
    }

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        // You can also register custom events in this class.
    }
    
}

Registering the GUI can be done in your plugin's main class by overriding the getGuis() function and adding a reference to your GUI's class to the array.

Example:

@Override
public Class<?>[] getGuis() {
    return new Class[] {
            MyGui.class
    };
}