Skip to content

Previous: GUIๅŠจไฝœไธŽๆกไปถ้€ŸๆŸฅ.md ยท Next: ่„šๆœฌๅ…ฅ้—จ.md Related: ่‡ชๅฎšไน‰GUI.md ยท ้…็ฝฎๆ–‡ไปถ.md ยท ็ปๆตŽAPI.md ยท ็ปๆตŽๆ’ไปถ.md

๐Ÿ’ฐ Economy Actions โ€‹

This page focuses on the three economy actions available in GUI click actions: give_money (grant currency), take_money (deduct currency), and set_money (set balance). It explains exactly how to write the value, and covers the differences between the Vault / PlayerPoints / ExcellentEconomy backends.

For the basic GUI structure, see ่‡ชๅฎšไน‰GUI.md. For the global configuration of the economy system, see the economy section in ้…็ฝฎๆ–‡ไปถ.md.


๐Ÿงฉ The Three Actions โ€‹

Action typeAliasesPurpose
give_moneygivemoneyGrant currency to the player
take_moneytakemoney,remove_moneyDeduct currency from the player (checks balance first; does not deduct if insufficient)
set_moneysetmoneySet the balance directly to a given value
yaml
click-actions:
  reward:
    type: give_money
    value: "500"

๐Ÿ“ Full value Syntax โ€‹

Unified format (EconomyActionParser):

[provider:][currency:]amount [| fail message]

Broken down into four parts:

PartRequired?Description
provider:OptionalWhich economy backend to use: vault / excellenteconomy / playerpoints / auto, with aliases ee / pp
currency:Depends on backendCurrency type (only ExcellentEconomy needs it)
amountRequiredA number; it is the last segment that can be parsed as a number among all segments
| fail messageOptionalSeparated by |; the text shown to the player when the operation fails (supports & codes)

๐Ÿ” Parsing Rules (follow these and you won't go wrong) โ€‹

  1. First, split the "body" from the "fail message" using |.
  2. Then split the body by :; the amount is always the last segment that can be parsed as a number.
  3. How prefix segments are recognized:
    • One prefix segment: if it is a known provider (vault/excellenteconomy/playerpoints/auto or the aliases ee/pp), it is treated as the provider; otherwise it is treated as the currency.
    • Two prefix segments: provider:currency.
    • No prefix (just a number): only the amount; provider/currency use their defaults.

๐Ÿ“‹ Parsing Examples Comparison โ€‹

value formprovidercurrencyamountfail message
100defaultdefault100โ€”
money:100defaultmoney100โ€”
vault:50vaultโ€”50โ€”
excellenteconomy:gold:100eegold100โ€”
100 | Insufficient balancedefaultdefault100Insufficient balance
excellenteconomy:money:50 | Not enough goldeemoney50Not enough gold

๐Ÿ’ก Note that in vault:50, vault is recognized as the provider, but in money:100, money is not a known provider, so it is treated as the currency. This is exactly the "one prefix segment" decision logic.


๐Ÿ”Œ Backend Differences (important) โ€‹

Backendprovider formcurrency handling
VaultvaultIgnores currency
PlayerPointsplayerpoints / ppIgnores currency
ExcellentEconomyexcellenteconomy / eecurrency must be specified, otherwise it reports CURRENCY_REQUIRED
  • Vault / PlayerPoints: single-currency systems. Whether or not you write currency:, it has no effect and is ignored. Just use vault:100 or pp:100.
  • ExcellentEconomy: a multi-currency system. You must state which currency, e.g. ee:gold:100. Omitting the currency will fail and report CURRENCY_REQUIRED.

๐Ÿค– auto Source Selection โ€‹

When provider is set to auto (or simply not written), the system automatically selects an available economy backend. This is suitable when you're unsure which economy plugin the server has installed, or when you want the configuration to be portable.

yaml
value: "auto:100"        # Automatically select a backend
value: "100"             # Omitting the provider is equivalent to using the default/auto

๐Ÿ“‹ Extensive Usage Examples โ€‹

yaml
# โ€”โ€” Simplest: grant 500 with the default backend โ€”โ€”
reward:
  type: give_money
  value: "500"

# โ€”โ€” Vault: deduct 100 (currency is ignored even if written) โ€”โ€”
pay:
  type: take_money
  value: "vault:100"

# โ€”โ€” PlayerPoints: grant 50 points using the alias pp โ€”โ€”
points:
  type: give_money
  value: "pp:50"

# โ€”โ€” ExcellentEconomy: currency is required โ€”โ€”
buy_gold:
  type: take_money
  value: "ee:gold:100"

# โ€”โ€” ExcellentEconomy full form + fail message โ€”โ€”
buy:
  type: take_money
  value: "excellenteconomy:money:50 | &cNot enough gold, cannot purchase"

# โ€”โ€” Specify only the currency; provider uses the default โ€”โ€”
spend:
  type: take_money
  value: "money:200"

# โ€”โ€” set_money: set the balance directly to 0 โ€”โ€”
reset:
  type: set_money
  value: "0"

# โ€”โ€” auto source selection + fail message โ€”โ€”
gift:
  type: give_money
  value: "auto:1000 | &cGrant failed, please contact an administrator"

๐Ÿ’ฌ Fail Messages and Default Messages โ€‹

The | fail message part is optional; when omitted, each action has a built-in default message. Below is what each action displays in different situations:

ActionSituationDisplayed content
give_moneyGrant failedfailMessage or &cFailed to grant currency
take_moneyInsufficient balanceFixed &cInsufficient balance (does not use failMessage)
take_moneyDeduction failed (balance sufficient but operation failed)failMessage or &cFailed to deduct currency
set_moneySet failedfailMessage or &cFailed to set balance
AllInvalid value format&cInvalid economy action format
AllEconomy system unavailablefailMessage or &cEconomy system unavailable

โš ๏ธ Key point: when take_money hits "insufficient balance", it displays the fixed &cInsufficient balance, and the | fail message you wrote will not take effect in that case. Your failMessage is only used when "the balance was sufficient but the actual deduction failed".


๐Ÿฉบ Common Errors and Troubleshooting โ€‹

SymptomPossible causeSolution
Shows &cInvalid economy action formatThe value is written incorrectly (e.g. the amount segment is missing, or it's all text)Compare against the syntax table above and make sure there is one segment that can be parsed as a number
Shows CURRENCY_REQUIREDUsed ExcellentEconomy but did not write a currencyChange it to ee:currencyName:amount, e.g. ee:gold:100
Shows &cEconomy system unavailableThe corresponding economy plugin is not installed / the provider name is misspelledInstall the plugin, or use auto, and check the provider spelling
Custom fail message not shownIt's the take_money insufficient-balance caseThat case always shows &cInsufficient balance and cannot be overridden; other failures do use failMessage
Written currency has no effectThe backend is Vault / PlayerPointsThey are single-currency, so currency is ignored by design โ€” this is normal
The amount is mistakenly recognized as the currencyThe segment order is reversedThe amount must be parseable as a number; arrange prefixes as provider:currency

๐Ÿ”Œ provider alias mnemonic: ee = excellenteconomy, pp = playerpoints.


๐Ÿ“– Further Reading โ€‹