-
Notifications
You must be signed in to change notification settings - Fork 13
GUIs
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 CCCache() {
super();
}
}And then set your class to the InventoryAPI. (Best in your plugins constructor!)
api.setInventoryAPI(new InventoryAPI<>(plugin, api, YourCache.class));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.
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);They contain multiple GuiWindows and Buttons. To create a GuiCluster you need to create a class that extends it.
public class YourCluster extends GuiCluster<YourCache> {
public YourCluster (InventoryAPI<YourCache> inventoryAPI, String id) {
super(inventoryAPI, id);
}
@Override
public void onInit() {
//Called on initialization! Used to register GuiWindows and Buttons.
registerWindow();
registerButton();
}
}They contain local Buttons and manage the logic to render the Buttons into the inventory. They are very similar to the GuiCluster and you need to create a class and extend it.
public class YourWindow extends GuiWindow<YourCache> {
public YourWindow(GuiCluster<YourCache> guiCluster, String key, int size) {
super(guiCluster, key, size);
}
@Override
public void onInit() {
//Called on initialization. Used to register Buttons.
registerButton();
}
@Override
public void onUpdateSync(GuiUpdate<YourCache> guiUpdate) {
//Updated sync
}
@Override
public void onUpdateAsync(GuiUpdate<YourCache> update) {
//Updated async
}
}| Home
| Registry
-
Introduction
- Structure
- InventoryAPI
- Register GuiCluster
- CustomCache
- GuiClusters
- GuiWindow
-
Buttons
- Dummy
- Action
- Toggle
- ChatInput
- MultipleChoice
-
ButtonStates
- ButtonFunctions
- ButtonAction
- ButtonPostAction
- ButtonPreRender
- ButtonRender
- ButtonFunctions