-
Notifications
You must be signed in to change notification settings - Fork 2
GuiFunctions
GuiEngine supports a wide variety of functions by default, enhancing the interactivity of your GUIs.
GuiEngine encompasses two primary types of GUI functions:
-
Compute Functions: These functions are intended to be inserted into your GUI file. During parsing for a specific player's GUI, these placeholders are substituted with computed values. They often take the form:
{@my.permission}
. -
Call Functions: Call functions, on the other hand, are restricted to usage within
on-
sections. These functions cannot be placed elsewhere. A typical call function appears like this:<on-click type="...">...</on-click>
.
This function enables you to access values from your components. It's useful for tasks like displaying the currently selected page.
Usage: {#id.method}
- The 'id' represents the component's ID you intend to target, while 'method' is the specific property you aim to access. Properties for each component are detailed in the Component documentation.
Example Usage (Non-functional components created here):
<component type="paged" id="container"/>
<component type="item" material="GRASS" name="§ePage {#container.getSelectedPage}"/> <!-- 'getSelectedPage' might be outdated; refer to the 'PageComponent' documentation -->
This function returns a boolean value, dependent on a permission check.
Usage: {@guinegine.reload}
- The permission you wish to check for follows the '@' symbol. Returns 'true' if the user possesses the permission.
Negated Usage: {!@guiengine.reload}
- Determines whether the user lacks the permission. Returns 'true' if absent.
Example Usage:
<component type="item" y="3" x="1" name="§eReload" hidden="{!@guiengine.reload}">
<head-texture>eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWNkOGNiNGY5OWJhOTQxNDJhYmY1NWY2MzRiZTdiNjk1YzcwZmJhMGQyYjA3NjVjYTg4YmM4ZTJlZWE0NjYzNiJ9fX0=</head-texture>
<on-click type="action">[player] guiengine reload</on-click>
</component>
<component type="item" y="3" x="1" name="§cReload" material="BARRIER" hidden="{@guiengine.reload}">
<lore/>
<lore>§7You are not permitted</lore>
<lore>§7to reload guiengine</lore>
</component>
This function will execute a action. Many actions are available by guiengine by default, but they can also be added by external plugins using guiengine. Checkout the wiki page about actions to see the list of actions available
TypeId: action
Parameters: [<action>] action-arguments
Example Usage:
<component type="item" y="1" x="6" material="RED_TERRACOTTA" name="§cDiscard Invite">
<on-click type="action">[player] f invitediscard %invite%</on-click>
<on-click type="action">[close]</on-click>
</component>
This function will make the execution of following functions pause.
TypeID: delay
Inlined Properties: unit
- Set the time unit. It defaults to SECONDS. Available time units:
-
DAYS
: Represents time in days. -
HOURS
: Represents time in hours. -
MINUTES
: Represents time in minutes. -
SECONDS
: Represents time in seconds. -
MILLISECONDS
: Represents time in milliseconds. -
MICROSECONDS
: Represents time in microseconds. -
NANOSECONDS
: Represents time in nanoseconds.
Paramaters: duration
Example Usage:
<component type="item" y="1" x="6" material="RED_TERRACOTTA" name="§cDiscard Invite">
<on-click type="action">[player] f invitediscard %invite%</on-click>
<on-click type="delay" unit="MINUTES">5</on-click> <!-- Waits for 5 minutes -->
<on-click type="action">[close]</on-click>
</component>
When called, this modifies the currently shown gui to add the component represented in the body.
TypeId: add
Parameters: component tree
<component type="item" y="1" x="6" material="RED_TERRACOTTA" name="§cDiscard Invite">
<on-click type="add">
<component type="item" y="1" x="6" material="GREEN_TERRACOTTA" name="§cDiscard Invite">
<on-click type="action">[message] You clicked this component!!</on-click>
</component>
</on-click>
</component>
<component type="item" y="1" x="6" material="RED_TERRACOTTA" name="§cDiscard Invite">
<on-click type="add">
<component type="item" y="1" x="6" material="GREEN_TERRACOTTA" name="§cDiscard Invite">
<on-click type="action">[message] You clicked this component!!</on-click>
</component>
<component type="item" y="1" x="7" material="YELLOW_TERRACOTTA" name="§cDiscard Invite">
<on-click type="action">[message] You clicked the other component!!</on-click>
</component>
</on-click>
</component>
Removes a component by it's id
TypeId: remove
Inlined parameters: target
Example Usage (Not functional page component):
<component type="paged" id="container"/>
<component type="item" y="1" x="6" material="RED_TERRACOTTA" name="§cDiscard Invite">
<on-click type="remove" target="container"/>
</component>
Edit a component
TypeId: edit
Inlined parameters:
-
target
- The component's id you want to edit -
attribute
- The component's attribute you want to edit -
set-value
- The new value for this attribute
Example Usage:
<component type="item" id="green-button" x="3" y="2" material="GREEN_TERRACOTTA" name="§aGreen button">
<lore>§7Click me</lore>
<lore>§7I promise §ait's worth§7 it</lore>
<on-click type="edit" target="green-button" attribute="name" set-value="§eYou clicked me :)"/>
<on-click type="edit" target="green-button" attribute="material" set-value="YELLOW_TERRACOTTA"/>
</component>
Thank you for choosing GuiEngine for your GUI development needs. Explore the Developer Docs and User Beginner Guide to unleash the full potential of this powerful framework and create stunning GUIs that leave a lasting impression on your players!