Adding Custom Currency

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:

public class TokensCurrency implements ICurrency {
}

Next, you'll need to add all the methods, your IDE may prompt you to do so:

public class TokensCurrency implements ICurrency {
@Override
public String getPluginName() {
// Set this to the name of the plugin being used
// You should also use this name (in uppercase) in the configuration
return "TokenPluginName";
}
@Override
public boolean onEnable(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 currency
return true;
}
@Override
public double getBalance(Player player) {
return yourplugin.getBalance(player); // your method to return balance
}
@Override
public void withdraw(Player player, double amount) {
yourplugin.withdrawAmount(player, amount); // your method to withdraw
}
}

Register the currency

Simply register the currency as shown below:

// Accessing the API
SponsoredSlotsAPI api = (SponsoredSlotsAPI) Bukkit.getPluginManager().getPlugin("SponsoredSlots");
// Register (internal) objective
api.registerCurrency(new TokensCurrency());