Skip to content

Built in Placeholder Document

TRCStudioDean edited this page Jun 3, 2025 · 11 revisions

Description

This is a document explaining the use of built-in placeholders in plugin,
They can be used in custom command configuration settings and support placeholder nesting (i.e., placeholders are included in the placeholder)
If you want to use the built-in placeholder replacement function of this plugin in other places (or other plugins), you can do it by: External Placeholder (PAPI)

Compass

Multi functional placeholders/custom placeholders

Special placeholders

Configurator Placeholder

Please ensure that the specified configuration table is loaded, otherwise no replacement will be made
About configurator: Configurator Document

Format Action
{[TableName]:[Path]} Replace with the value corresponding to the specified path
{[TableName]:[Path]:[Index]} Replace with the Nth element in the list corresponding to the specified path
{[TableName]_jsondata} Replace with JSON text of configuration table

Note: If the value of the specified path is a list, the value of the Nth element in the list can be obtained based on [Index]
Example:
If the configuration table looks like this (YAML format)

#Table name: Test
ExampleValue:
    Section1: 'Birthday'
    Section2: 20150811
    Section3: true
    List:
    - '1th'
    - '2th'
    - '3th'

The following is the effect of placeholder replacement

Format Result
{Test:ExampleValue.Section1} Birthday
{Test:ExampleValue.Section2} 20150811
{Test:ExampleValue.List:2} 2th
{Test_jsondata} {"ExampleValue": {"Section3": true,"Section1": "Birthday","Section2": 20150811,"List": ["1th","2th","3th"]}}

Arithmetic Placeholder

Format: {calculate:[Expression]}
Action: Used to calculate the specified expression and replace the placeholder. (Supports parenthesis operation, it is recommended to nest it with other placeholders)
Note: If there is an error in the arithmetic expression, the placeholder will not be replaced.
Example:

Command-Executor:
    'Example1':
        Conditions:
        - '{length} >= 1'
        Break: true
        Functions:
            'Example1':
                Conditions:
                - 'number:isDouble:{calculate:[1]}' #Check if the calculation result is a number
                Break: true
                Messages:
                - 'The calculation result of the expression you entered is: {calculate:[1]}'
                - 'If this is the radius of a circle, then the area of the circle is: {calculate:{calculate:[1]} * {calculate:[1]} * 3.14}'
            'Example2':
                Messages:
                - 'The arithmetic expression you entered is incorrect!'
    'Example2':
        Messages:
        - 'Please enter an arithmetic expression!'

Colourless Placeholder

Format: {colourless:[Text]}
Action: If the content in [Text] contains color symbols or hexadecimal color expressions, they will not undergo staining.
Notice: In each line of the message, the placeholder will only be fully replaced once. (which means that the writing of {colourless:{colourless:...}} is invalid)
Example:

Command-Executor:
    'Example1':
        Messages:
        - '{colourless:&aThis is an colourless article}'
        - '&aThis is an colored article'

Raw Content Placeholder

Format: {raw:[Text]}
Action: If the content in [Text] contains placeholders of other '{...}' format types, they will not be replaced.
Notice: In each line of the message, the placeholder will only be fully replaced once. (which means that the writing of {raw:{raw:...}} is invalid)
Example:

Command-Executor:
    'Example1':
        Messages:
        - '{raw:Server Name: {server:name}} (Unable to display)'
        - 'Server Name: {server:name}'

Player Attributes Placeholder Example

Command-Executor:
    'Example1':
        Conditions:
        - '{sender_type} == Player'
        Break: true
        Messages:
        - 'Hello {player:{sender}:display_name} !'
        - 'Your IP address: {player:{sender}:address}'
        - 'Your ping: {player:{sender}:ping}'
        - 'Your location: {player:{sender}:location_x}, {player:{sender}:location_y}, {player:{sender}:location_z}'
    'Example2':
        Messages:
        - 'This command can only be used by player!'

World Attributes Placeholder Example

Command-Executor:
    'Example1':
        Conditions:
        - '{length} >= 1'
        - 'world:[1]' #Check if the name specified in the first subcommand is a valid world name
        Break: true
        Functions:
            'Example1':
                Conditions:
                - '{world:[1]:game_rule_value_keepInventory}'
                Break: true
                Messages:
                - 'You are viewing information for world {world:[1]:name}:'
                - 'Spawn location: {world:[1]:spawn_location_x}, {world:[1]:spawn_location_y}, {world:[1]:spawn_location_z}'
                - 'Keep inventory: Yes'
            'Example2':
                Messages:
                - 'You are viewing information for world {world:[1]:name}:'
                - 'Spawn location: {world:[1]:spawn_location_x}, {world:[1]:spawn_location_y}, {world:[1]:spawn_location_z}'
                - 'Keep inventory: No'
    'Example2':
        Messages:
        - 'You need to enter a valid world name!'

Server Attributes Placeholder Example

Command-Executor:
    'Example':
        Messages:
        - 'Bukkit version: {server:bukkit_version}'
        - 'Server address: {server:ip}:{server:port}'
        - 'Online players: {server:online_players}/{server:max_players}'

Clone this wiki locally