Adding your own currency is a straight forward process. First of all, ensure you have the API dependency loaded into your project and set it as a depend in your plugin.yml file.
Create your currency class that implements ICurrency:
publicclassTokensCurrencyimplementsICurrency {}
Next, you'll need to add all the methods, your IDE may prompt you to do so:
publicclassTokensCurrencyimplementsICurrency { @OverridepublicStringgetPluginName() {// Set this to the name of the plugin being used// You should also use this name (in uppercase) in the configurationreturn"TokenPluginName"; } @OverridepublicbooleanonEnable(JavaPlugin plugin) {// load anything required for your currency, such as an instance of// the plugin and return true if successful// or return false if you were not able to load your currencyreturntrue; } @OverridepublicdoublegetBalance(Player player) {returnyourplugin.getBalance(player); // your method to return balance } @Overridepublicvoidwithdraw(Player player,double amount) {yourplugin.withdrawAmount(player, amount); // your method to withdraw }}
Register the currency
Simply register the currency as shown below:
// Accessing the APISponsoredSlotsAPI api = (SponsoredSlotsAPI) Bukkit.getPluginManager().getPlugin("SponsoredSlots");// Register (internal) objectiveapi.registerCurrency(newTokensCurrency());