Developer API

Example usage of how to use the plugin's api

Check all custom events that are available on the plugin.

Custom Eventschevron-right

Getting Player Data

Normally you will use this to modify/get player's mobcoins. Keep in mind, method MobCoinsAPI#getPlayerData is nullable, so you'll have to null-check it first for safety.

Example Usage
public void modifyPlayerCoins(Player player){
    // Firstly we get the player data
    PlayerData playerData = MobCoinsAPI.getPlayerData();
    // Return if the player data is null
    if(playerData == null){
        // Print something into the console
        System.out.println("Modify Coins failed (reason: null player data)");
        return;
    }
    // Now we can modify anything on the player data
    // Adding coins to the player data
    playerData.addCoins(10.25);
    // Removing coins
    playerData.removeCoins(5.50);
    // See how much mobcoins does player have
    System.out.println(player.getName() + " has " + playerData.getCoinsFormatted() + " coins");
}
circle-info

Feel free to contact us If you want something to be added to the plugin's API.

Last updated