Developer API

Here you can find all the information on how to use our API to add custom economies.

Creating a custom economy provider is a fairly 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.


To being with we need to create a class and have it extend EconomyProvider some IDEs will then prompt you to add the missing values. In this example we will call our class CustomEconomy

public class CustomEconomy extends EconomyProvider {
}

After that is finished if your IDE does not prompt you to add in the missing values you must do so manually here you can find how they should look.

public class CustomEconomy extends EconomyProvider {

    public CustomEconomy(String identifier) {
        super("CUSTOM_ECONOMY");
    }

    @Override
    public void onEnable() {

    }

    @Override
    public double getBalance(OfflinePlayer player) {
        return 0;
    }

    @Override
    public void withdraw(OfflinePlayer player, double amount) {

    }

    @Override
    public void deposit(OfflinePlayer player, double amount) {

    }
}

Now all you must do is update each method with the relevant code to work with your plugin. It is recommended to define the API in the onEnable method. Below we will provide an example using the TokenManager plugin

    @Override
    public void onEnable() {
        tokenManager = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
    }

Now all we must do is register the objective an example of this can be seen below.

// Accessing the API
DeluxeCoinflipAPI api = (DeluxeCoinflipAPI) Bukkit.getPluginManager().getPlugin("DeluxeCoinflip");

// Register the custom economy. 
// Be sure to replace YOUR_PLUGIN with the name of your plugin for it to be registered correctly.
api.registerEconomyProvider(new CustomProvider, "YOUR_PLUGIN");

Make sure DeluxeCoinflip has been added as a depend in your plugin.yml to ensure it loads correctly.

Last updated