Skip to content

GuiFunctions

Tobero edited this page Aug 31, 2023 · 10 revisions

Functions

Javadoc ToberoCat - GuiEngine Donate PayPal stars - GuiEngine forks - GuiEngine GitHub release issues - GuiEngine SpigotMain - GuiEngine


Functions

GuiEngine supports a wide variety of functions by default, enhancing the interactivity of your GUIs.

Function Types

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>.

Compute Functions

Component Property Function

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):

<component type="paged" id="container"/>
<component type="item" material="GRASS" name="§ePage {#container.getSelectedPage}"/> <!-- 'getSelectedPage' might be outdated; refer to the 'PageComponent' documentation -->

Permission Function

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>

Call functions

Action Function

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>

Delay Action

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>
```

### 
Clone this wiki locally