Actions System

Actions System Documentation

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] &aYou have 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:

[SOUND] <sound>;[volume];[pitch]

Example:

[SOUND] ENTITY_PLAYER_LEVELUP;1.0;1.0

4. [TITLE]

Displays a title and subtitle to the player.

Syntax:

[TITLE] <title>;<subtitle>;<fadeIn>;<stay>;<fadeOut>

Example:

[TITLE] &a&lCongratulations!;&7You redeemed a voucher.;10;70;20

5. [ACTION_BAR]

Displays a message in the player's action bar.

Syntax:

[ACTION_BAR] <message>

Example:

[ACTION_BAR] &aYou have unlocked a special reward!

6. [RANDOM]

Executes a set of actions with a specified chance. If the chance is met, all actions in the set are executed.

Syntax:

[RANDOM] <chance>:<action1>|<action2>|...

Example:

[RANDOM] 50:[MESSAGE] &aYou won a prize!|[COMMAND] give %player% diamond 5

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:

[SET_VAR] <variable_name> <value>

Example:

[SET_VAR] random_amount %random_1_5%

8. [VAR]

References a previously set variable. Use %var_<variable_name>% to insert the variable's value into an action.

Example:

[MESSAGE] &aYou won %var_random_amount% diamonds!

9. [COLOR]

Supports color codes and hex values for messages, titles, and action bars. Use & for color codes and # for hex values.

Syntax:

[MESSAGE] <message_with_color>

Example:

[MESSAGE] &6&lGolden Reward! #FFD700&lYou have won a prize!

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

redeem-actions:
  - "[MESSAGE] &aYou redeemed your voucher!"
  - "[COMMAND] give %player% diamond 1"

Example 2: Randomized Rewards

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"

Example 3: Using Variables

redeem-actions:
  - "[SET_VAR] random_amount %random_1_5%"
  - "[MESSAGE] &aYou won %var_random_amount% diamonds!"
  - "[COMMAND] give %player% diamond %var_random_amount%"

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.

Last updated