SkVault allows Vault to hook into your economy script so other plugins (including Skript) can use your custom economy.
Economy properties define information about your custom economy:
#economy-name: MyEconomy
#currency-name: dollar
#currency-name-plural: dollars
#currency-format: $%number%
#decimal-places: 2
#auto-link-var: {balances::%player's uuid%}
They are defined in comments because some plugins (including Skript) request these values before scripts load. For this reason, you must restart your server to update economy properties, reloading the script will not update them. The properties can be in any order, anywhere in your script. You do not have to define all of the economy properties, but if Vault requests a property that you have not defined then an UnsupportedOperationException will be thrown.
Enabling automatic linking will make SkVault automatically handle economy requests from Vault. To enable automatic linking set the auto-link-var
economy property to the variable that you want to hold the player balances.
Example:
#auto-link-var: {balances::%player's uuid%}
Requests from Vault will now be handled automatically using the variable you set. This is adequate for most users but if you would like full control over requests from Vault use Vault request events.
Vault request events are for users who want to be able to fully control what happens when Vault requests something from their economy. The format of a Vault request event is:
on vault <something> request:
return <something> to the request
In the syntax list, the request events will have (Return: number/boolean/string/economy response)
in their title which tells you the type of value that should be returned. Some events expect a simple value such as a number and others expect you to return an economy response. An economy response gives Vault information about the actions you took upon receiving a request.
Example 1:
on vault player balance request:
return {balances::%event-offlineplayer's uuid%}
Example 2:
on vault balance deposit request:
add event-number to {balances::%event-offlineplayer's uuid%}
return economy response with amount modified event-number, new balance {balances::%event-offlineplayer's uuid%}, response type success, and error message "none"
The complete list of Vault request event is available in the syntax section.
If Vault requests an economy property that you have not defined or if you did not return a value in a request event then you will see a UnsupportedOperationException
stacktrace in console. To fix these errors simply define the requested economy property or implement the specified request event.
Example:
...
[21:01:41 ERROR]: #!#! Stack trace:
[21:01:41 ERROR]: #!#! java.lang.UnsupportedOperationException: BalanceRequestEvent
[21:01:41 ERROR]: #!#! at us.donut.skvault.events.VaultRequestEvent.getReturnValue(VaultRequestEvent.java:30)
[21:01:41 ERROR]: #!#! at us.donut.skvault.CustomEconomy.getBalance(CustomEconomy.java:127)
[21:01:41 ERROR]: #!#! at us.donut.skvault.CustomEconomy.getBalance(CustomEconomy.java:200)
[21:01:41 ERROR]: #!#! at ch.njol.skript.hooks.economy.expressions.ExprBalance.convert(ExprBalance.java:57)
...
In this case, Vault tried to get the balance of a player but automatic linking was not enabled and the balance request event was not implemented so an UnsupportedOperationException
was thrown.
Called when Vault requests to deposit currency into a player's balance
on vault deposit request:
add event-number to {balances::%event-offlineplayer's uuid%}
return economy response with amount modified event-number, new balance {balances::%event-offlineplayer's uuid%}, response type success, and error message "none"
Syntaxes
[on] [vault] [player] [bal[ance]] deposit request
Event values
event-number
event-offlineplayer
Since |
2.0 | false |
---|
Called when Vault requests to withdraw currency from a player's balance
on vault withdraw request:
remove event-number from {balances::%event-offlineplayer's uuid%}
return economy response with amount modified event-number, new balance {balances::%event-offlineplayer's uuid%}, response type success, and error message "none"
Syntaxes
[on] [vault] [player] [bal[ance]] withdraw request
Event values
event-number
event-offlineplayer
Since |
2.0 | false |
---|
Called when Vault requests to know if a player's balance is greater than a certain amount
on vault check player balance request:
if {balances::%event-offlineplayer's uuid%} is greater than event-number:
return true
else:
return false
Syntaxes
[on] [vault] check [player] bal[ance] request
Event values
event-number
event-offlineplayer
Since |
2.0 | false |
---|
Called when Vault requests a player economy account to be created
on vault create player account request:
set {balances::%event-offlineplayer's uuid%} to 0
return true
Syntaxes
[on] [vault] create [player] [eco[nomy]] account request
Event values
event-offlineplayer
Since |
2.0 | false |
---|
Called when Vault requests to know if a player has an economy account
on vault player has account request:
if {balances::%event-offlineplayer's uuid%} is set:
return true
else:
return false
Syntaxes
[on] [vault] [player] has [eco[nomy]] account request
Event values
event-offlineplayer
Since |
2.0 | false |
---|
Called when Vault requests a player's balance
on vault player balance request:
return {balances::%event-offlineplayer's uuid%}
Syntaxes
[on] [vault] [player] bal[ance] [value] request
Event values
event-offlineplayer
Since |
2.0 | false |
---|
Returns a value to a request from Vault
No examples available yet.
Syntaxes
return %object% [to [the] [vault] request]
Since |
2.0 |
---|
No description available yet.
No examples available yet.
Syntaxes
[a] [new] eco[nomy] response [with] [amount [modified]] %number%, [new] [bal[ance]] %number%, [[response] type] (success|failure|not implemented), [and] [error [message]] %string% [to [the] [vault] request]
Since |
1.0 | Return type
| Object | none |
---|