-
Notifications
You must be signed in to change notification settings - Fork 1
Using Currencies
On this page, you can find documentation about managing currencies.
To get a currency, use the Currency
class. The currency class contains methods to get & set players' balance, as well as methods to change currency properties.
You can make a currency variable, or just use the constructor when managing currencies. I recommend making a currency variable when you want to use a currency method two or more times, and directly using the constructor if you just need to do a single thing with a currency.
When using the constructor, if the given currency does not exist, it will be made.
To add, remove and set balance, use Currency#<changeType>Balance
.
Getting a player's balance is almost the same, with the method being Currency#getBalance
.
Here's an example:
Currency currency = new Currency("currencyName");
currency.setBalance(playerUUID, 10.76);
Bukkit.getServer().broadcastMessage(currenct.getBalance(playerUUID).toString());
To delete a currency, use Currency#delete
. The method is non-static, so don't worry about deleting an non-existing currency. You can also change the min, max & starting balance of a currency by using Currency#set<property>
. To set a provider, you need access to the specific provider's class, which must be extending the CurrencyProvider
class. To read more about providers, visit this page.
Note that from commit
35542f5
(v1.0) all the static methods, as well as the non-staticCurrency#hasBalance
deprecated.