-
Notifications
You must be signed in to change notification settings - Fork 0
GUI Contents For Developers
This section is dedicated to server admins. If you are looking for the developers' page, click here
Many of the fields referenced on this page might be or require platform-specific values. Check the glossary
In this guide, we will go over the creation and management of GUI contents, the elements that will be displayed upon opening the GUIs. The goal of this page is to teach the developer how they can create, manage interactions and special effects with these special objects.
At the moment, only one implementation is present: ItemGUIContent. Since this class inherits from Item, its creation is very similar to the one of items, thanks to the method chaining system:
ItemGUIContent.newInstance("stone_sword").setDisplayName("Strong sword").setDurability(1337);
This means that all the Item methods are available, and the content can be handled as such.
One might even create an Item first, and then convert it to an ItemGUIContent thanks to the copy(Class)
method:
Item.newItem().setMaterial("dye").setDurability(4).setDisplayName("&9Custom Lapis Lazuli").copy(ItemGUIContent.class);
However, GUI contents allow further customization and more control over normal items. We will go through each option one by one to analyze them deeply and understand their meaning:
Table of contents |
---|
Requirements |
Priorities |
Sound |
Actions |
Variables |
The priority allows defining which content should be displayed first in the case of a conflict.
Being of type int
, negative values are allowed, but natural numbers are to be preferred.
The content with higher priority will be displayed first.
GUIContent content = ItemGUIContent.newInstance();
// ...
content.setPriority(10);
As the names of the methods suggest, a sound for clicking with the content can be specified. The sound has to be of type Sound from the wrappers module.
GUIContent content = ItemGUIContent.newInstance();
// ...
content.setClickSound(new Sound("VILLAGER_HAPPY", 10.0F, 1.0F));
Similarly to what happens for GUIs, also contents accept variables that can be declared in this section. They will be then replaced upon displaying the full content:
GUIContent content = ItemGUIContent.newInstance();
// ...
content.setVariable("name", "Strong sword");