Freemarker

The default templating engine used by Tubing is Freemarker. It is a very basic Java templating engine which we can use to dynamically build our Tubing GUI XML.

When using the Freemarker templating engine, Tubing provides us with some utility methods that can be used inside the template.

Permission check

The are 2 types of permission checks that we can use inside the templates.

$permissions

$permissions is a utility class that can be used inside the Freemarker templates. The "has" method can check if a player has a certain permission. The "player" variable is also provided by Tubing. It is the player that has opened the GUI.

<#if $permissions.has(player, "appeals.approve")>
        <GuiItem slot="34"
                id="mute-appeal-approve"
                material="GREEN_GLAZED_TERRACOTTA"
                class="mute-appeal-approve appeal-approve"
                onLeftClick="manage-mute-appeals/approve?appealId=${appeal.id}">
           <name class="item-name">
                   <@translate key="gui.mutes.appeal-detail.approve.title"/>
           </name>
        </GuiItem>
</#if>

permission attribute

The Tubing GUI XML also provides a permission attribute. As can be seen in the XSD scheme. The permission attribute will hide the element if the current player does not have the provided permission.

<GuiItem id="teleport-to-player"
    slot="21"
    permission="teleport-to-player"
    onLeftClick="teleport?targetPlayerName=${target.username}"
    material="MAGENTA_GLAZED_TERRACOTTA">
    <name class="item-name">Teleport to</name>
</GuiItem>

Last updated