Actions
Actions are commands or effects that execute when a voucher is used. CocoVouchers supports multiple action types with a flexible syntax.
Action Syntax
[ACTION_TYPE] value
Actions are defined in the actions list:
actions:
- "[MESSAGE] &aYou received a reward!"
- "[CONSOLE] give %player% diamond 64"
- "[SOUND] ENTITY_PLAYER_LEVELUP,1,1"
Action Types
MESSAGE
Sends a message to the player.
- "[MESSAGE] &aYou redeemed the voucher!"
- "[MESSAGE] &#FF6B35Welcome to VIP!"
CONSOLE
Executes a command from console.
- "[CONSOLE] give %player% diamond 64"
- "[CONSOLE] lp user %player% parent set vip"
- "[CONSOLE] eco give %player% 1000"
PLAYER
Executes a command as the player.
- "[PLAYER] spawn"
- "[PLAYER] warp vip"
- "[PLAYER] say I just claimed a voucher!"
SOUND
Plays a sound to the player.
Format: SOUND_NAME,volume,pitch
- "[SOUND] ENTITY_PLAYER_LEVELUP,1,1"
- "[SOUND] BLOCK_NOTE_BLOCK_PLING,0.5,2"
- "[SOUND] UI_TOAST_CHALLENGE_COMPLETE,1,1"
Common Sounds:
| Sound | Description |
|---|---|
ENTITY_PLAYER_LEVELUP | Level up sound |
ENTITY_EXPERIENCE_ORB_PICKUP | XP pickup |
BLOCK_NOTE_BLOCK_PLING | Note block pling |
UI_TOAST_CHALLENGE_COMPLETE | Achievement sound |
BROADCAST
Sends a message to all online players.
- "[BROADCAST] &e%player% &ajust claimed a legendary crate!"
EFFECT
Applies a potion effect to the player.
Format: EFFECT_NAME,duration,amplifier
- "[EFFECT] SPEED,600,1"
- "[EFFECT] REGENERATION,200,2"
- "[EFFECT] NIGHT_VISION,6000,0"
- Duration is in ticks (20 ticks = 1 second)
- Amplifier is level - 1 (0 = Level I, 1 = Level II)
ACTIONBAR
Displays an action bar message.
- "[ACTIONBAR] &6+500 Coins received!"
TITLE
Displays a title and subtitle.
Format: title;subtitle;fadeIn;stay;fadeOut
- "[TITLE] &6&lCONGRATULATIONS!;&eYou won a rare reward!;10;70;20"
- Times are in ticks (20 = 1 second)
BOSSBAR
Displays a boss bar message.
Format: message;color;style;duration
- "[BOSSBAR] &aVoucher Redeemed!;GREEN;SOLID;100"
Colors: PINK, BLUE, RED, GREEN, YELLOW, PURPLE, WHITE
Styles: SOLID, SEGMENTED_6, SEGMENTED_10, SEGMENTED_12, SEGMENTED_20
Placeholders
Use these placeholders in any action:
| Placeholder | Description |
|---|---|
%player% | Player's name |
%uuid% | Player's UUID |
%voucher% | Voucher name |
PlaceholderAPI placeholders also work if installed:
- "[MESSAGE] Your balance: %vault_eco_balance%"
Chance Actions
Actions with a percentage chance to execute:
chance-actions:
- chance: 50
actions:
- "[MESSAGE] &eYou got lucky! (50% chance)"
- "[CONSOLE] give %player% nether_star 1"
- chance: 10
actions:
- "[MESSAGE] &6&lJACKPOT! (10% chance)"
- "[CONSOLE] give %player% diamond_block 64"
Each group has its own independent chance.
Random Actions
Weighted random selection - only one action per group triggers:
random-actions:
- amount: 1 # How many to pick
actions:
- "[MESSAGE] {10} Common reward (weight 10)"
- "[MESSAGE] {50} Uncommon reward (weight 50)"
- "[MESSAGE] {100} Rare reward (weight 100)"
Weight Syntax: {weight} before the action
Higher weight = more likely to be selected.
Weight Calculation
With weights 10, 50, 100 (total 160):
- Common: 10/160 = 6.25%
- Uncommon: 50/160 = 31.25%
- Rare: 100/160 = 62.5%
Combined Example
actions:
# Always execute
- "[MESSAGE] &aThanks for redeeming!"
- "[SOUND] ENTITY_PLAYER_LEVELUP,1,1"
chance-actions:
# 25% bonus
- chance: 25
actions:
- "[MESSAGE] &e+25% Bonus coins!"
- "[CONSOLE] eco give %player% 250"
random-actions:
# Pick 2 random rewards
- amount: 2
actions:
- "[CONSOLE] {50} give %player% diamond 1"
- "[CONSOLE] {30} give %player% emerald 3"
- "[CONSOLE] {20} give %player% gold_ingot 10"