Skip to main content

đŸ”ĸ Global Variables

Introduction​

A global variable is a type of variable that can be accessed in any context and is widely applicable in various scenarios such as expressions and item data.

Here is a basic example, where tags in the format <arg:0> are optional parameters that can be dynamically provided by the caller:

global-variables:
test: "<!i><#FF8C00><arg:0>'s <arg:1>"
items:
default:topaz_rod:
client-bound-data:
item-name: "<global:test:'<arg:player.name>':'<i18n:item.topaz_rod>'>"
tip

CraftEngine's global variables are also accessible to other plugins, though it should be noted that their implementation operates through text replacement at the packet level. This approach does not interfere with the functional logic or internal operations of the recipient plugins.

Furthermore, by design, these global variables DO NOT support passing additional parameters. This limitation is intentional and helps maintain optimal performance.

Below are several common use cases with examples:

  1. Parsing variables for plugins that do not support PlaceholderAPI
global-variables:
money: "<papi:vault_eco_balance>"
# Bossbar configuration in another plugin
bossbar: "Current coins: <global:money>"
  1. Using rich text formatting in plugins that do not support MiniMessage
global-variables:
coin_without_shadow: "<!shadow><image:default:icons>"
# Hologram configuration in another plugin
line: "<global:coin_without_shadow> My coins: %vault_eco_balance%"