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 type | Aliases | Purpose |
|---|---|---|
give_money | givemoney | Grant currency to the player |
take_money | takemoney,remove_money | Deduct currency from the player (checks balance first; does not deduct if insufficient) |
set_money | setmoney | Set the balance directly to a given value |
click-actions:
reward:
type: give_money
value: "500"๐ Full value Syntax โ
Unified format (EconomyActionParser):
[provider:][currency:]amount [| fail message]Broken down into four parts:
| Part | Required? | Description |
|---|---|---|
provider: | Optional | Which economy backend to use: vault / excellenteconomy / playerpoints / auto, with aliases ee / pp |
currency: | Depends on backend | Currency type (only ExcellentEconomy needs it) |
amount | Required | A number; it is the last segment that can be parsed as a number among all segments |
| fail message | Optional | Separated by |; the text shown to the player when the operation fails (supports & codes) |
๐ Parsing Rules (follow these and you won't go wrong) โ
- First, split the "body" from the "fail message" using
|. - Then split the body by
:; the amount is always the last segment that can be parsed as a number. - How prefix segments are recognized:
- One prefix segment: if it is a known provider (
vault/excellenteconomy/playerpoints/autoor the aliasesee/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.
- One prefix segment: if it is a known provider (
๐ Parsing Examples Comparison โ
value form | provider | currency | amount | fail message |
|---|---|---|---|---|
100 | default | default | 100 | โ |
money:100 | default | money | 100 | โ |
vault:50 | vault | โ | 50 | โ |
excellenteconomy:gold:100 | ee | gold | 100 | โ |
100 | Insufficient balance | default | default | 100 | Insufficient balance |
excellenteconomy:money:50 | Not enough gold | ee | money | 50 | Not enough gold |
๐ก Note that in
vault:50,vaultis recognized as the provider, but inmoney:100,moneyis not a known provider, so it is treated as the currency. This is exactly the "one prefix segment" decision logic.
๐ Backend Differences (important) โ
| Backend | provider form | currency handling |
|---|---|---|
| Vault | vault | Ignores currency |
| PlayerPoints | playerpoints / pp | Ignores currency |
| ExcellentEconomy | excellenteconomy / ee | currency 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 usevault:100orpp:100. - ExcellentEconomy: a multi-currency system. You must state which currency, e.g.
ee:gold:100. Omitting the currency will fail and reportCURRENCY_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.
value: "auto:100" # Automatically select a backend
value: "100" # Omitting the provider is equivalent to using the default/auto๐ Extensive Usage Examples โ
# โโ 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:
| Action | Situation | Displayed content |
|---|---|---|
give_money | Grant failed | failMessage or &cFailed to grant currency |
take_money | Insufficient balance | Fixed &cInsufficient balance (does not use failMessage) |
take_money | Deduction failed (balance sufficient but operation failed) | failMessage or &cFailed to deduct currency |
set_money | Set failed | failMessage or &cFailed to set balance |
| All | Invalid value format | &cInvalid economy action format |
| All | Economy system unavailable | failMessage or &cEconomy system unavailable |
โ ๏ธ Key point: when
take_moneyhits "insufficient balance", it displays the fixed&cInsufficient balance, and the| fail messageyou 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 โ
| Symptom | Possible cause | Solution |
|---|---|---|
Shows &cInvalid economy action format | The 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_REQUIRED | Used ExcellentEconomy but did not write a currency | Change it to ee:currencyName:amount, e.g. ee:gold:100 |
Shows &cEconomy system unavailable | The corresponding economy plugin is not installed / the provider name is misspelled | Install the plugin, or use auto, and check the provider spelling |
| Custom fail message not shown | It's the take_money insufficient-balance case | That case always shows &cInsufficient balance and cannot be overridden; other failures do use failMessage |
| Written currency has no effect | The backend is Vault / PlayerPoints | They are single-currency, so currency is ignored by design โ this is normal |
| The amount is mistakenly recognized as the currency | The segment order is reversed | The amount must be parseable as a number; arrange prefixes as provider:currency |
๐ provider alias mnemonic:
ee=excellenteconomy,pp=playerpoints.
๐ Further Reading โ
- โ๏ธ ้
็ฝฎๆไปถ.md โ the
economyconfiguration section (default provider, toggles) - ๐ผ๏ธ ่ชๅฎไนGUI.md โ the GUI structure where economy actions live
- ๐ GUIๅจไฝไธๆกไปถ้ๆฅ.md โ pair with the
moneyvisibility condition to build purchase buttons - ๐งฐ ็ปๆตAPI.md โ for developers calling the economy interface directly
- ๐ ็ปๆตๆไปถ.md โ integrating Vault / PlayerPoints / ExcellentEconomy