Skip to content
WolfyScript edited this page Feb 20, 2022 · 8 revisions

Structure

The GUI API follows a structure to make it consistent as possible and easily manageable.

It has the following main parts:

  • InventoryAPI - contains all of the data and is the parent of everything.
  • GuiCluster - a cluster of multiple GuiWindows.
  • GuiWindow - a window that contains all the logic and buttons to render the items into the Inventory.
  • Buttons - used to render interactive ItemStacks into the GUI.

InventoryAPI

You can get the instance via the WolfyUtilities object.
If you use the default CustomCache you need to use InventoryAPI<CustomCache> else InventoryAPI<YourCache>. Same for every object that requires the cache type.

//For default cache
InventoryAPI<CustomCache> invAPI = api.getInventoryAPI(CustomCache.class);

//For your custom cache
InventoryAPI<YourCache> invAPI = api.getInventoryAPI(YourCache.class);

Register GuiCluster

You can register your GuiClusters using the registerCluster() like:

invAPI.registerCluster(new YourCluster(invAPI));

CustomCache

You'll see that many components part of the InventoryAPI are using the CustomCache object.
It allows to cache data for players, which might be important for the functionality of your GUI.
For each player, the API will create a new CustomCache instance.

By default, the CustomCache class doesn't contain lots of flexibility, so for more advanced usage, you should create your own class.

public class YourCache extends CustomCache {
    
    public YourCache() {
        super();
    }   

}

And then set your class to the InventoryAPI. (Best in your plugins constructor!)

api.setInventoryAPI(new InventoryAPI<>(plugin, api, YourCache.class));

| Home

| GUIs

| NBT Tools

Clone this wiki locally