The Actions System in Phantom Vouchers allows you to define custom behaviors that are executed when a voucher is redeemed. Actions are specified in the redeem-actions section of a voucher configuration file and are executed in the order they are listed. The system supports a variety of actions, including commands, messages, sounds, and more.
Supported Actions
1. [MESSAGE]
Sends a message to the player who redeemed the voucher.
Syntax:
[MESSAGE] <message>
Example:
[MESSAGE]&aYouhave redeemed your voucher!
2. [COMMAND]
Executes a server command as if it were run by the console. Use %player% to reference the player who redeemed the voucher.
Syntax:
[COMMAND] <command>
Example:
[COMMAND]give %player% diamond 1
3. [SOUND]
Plays a sound to the player who redeemed the voucher.
Syntax:
Example:
4. [TITLE]
Displays a title and subtitle to the player.
Syntax:
Example:
5. [ACTION_BAR]
Displays a message in the player's action bar.
Syntax:
Example:
6. [RANDOM]
Executes a set of actions with a specified chance. If the chance is met, all actions in the set are executed.
Syntax:
Example:
7. [SET_VAR]
Sets a variable to a value, which can be used in subsequent actions. Supports placeholders like %random_<min>_<max>% for generating random numbers.
Syntax:
Example:
8. [VAR]
References a previously set variable. Use %var_<variable_name>% to insert the variable's value into an action.
Example:
9. [COLOR]
Supports color codes and hex values for messages, titles, and action bars. Use & for color codes and # for hex values.
Syntax:
Example:
Notes:
Hex values must start with # and can be used alongside traditional color codes.
Supported in [MESSAGE], [TITLE], and [ACTION_BAR] actions.
Advanced Examples
Example 1: Simple Reward
Example 2: Randomized Rewards
Example 3: Using Variables
Notes
Actions are executed in the order they are listed unless a [RANDOM] action is used.
Variables set with [SET_VAR] can be reused in subsequent actions.
Ensure proper syntax to avoid errors during execution.
For more information or assistance, refer to the plugin's documentation or contact support.
[TITLE] &a&lCongratulations!;&7You redeemed a voucher.;10;70;20
[ACTION_BAR] <message>
[ACTION_BAR] &aYou have unlocked a special reward!
[RANDOM] <chance>:<action1>|<action2>|...
[RANDOM] 50:[MESSAGE] &aYou won a prize!|[COMMAND] give %player% diamond 5
[SET_VAR] <variable_name> <value>
[SET_VAR] random_amount %random_1_5%
[MESSAGE] &aYou won %var_random_amount% diamonds!
[MESSAGE] <message_with_color>
[MESSAGE] &6&lGolden Reward! #FFD700&lYou have won a prize!
redeem-actions:
- "[MESSAGE] &aYou redeemed your voucher!"
- "[COMMAND] give %player% diamond 1"
redeem-actions:
- "[RANDOM] 50:[MESSAGE] &aYou won a rare item!|[COMMAND] give %player% emerald 5"
- "[RANDOM] 20:[MESSAGE] &aYou won a legendary item!|[COMMAND] give %player% nether_star 1"
redeem-actions:
- "[SET_VAR] random_amount %random_1_5%"
- "[MESSAGE] &aYou won %var_random_amount% diamonds!"
- "[COMMAND] give %player% diamond %var_random_amount%"