Account balance

Discussion in 'Spigot Plugin Development' started by karolyik13, Nov 10, 2018.

  1. I want to write an account balance plugin.
    How can I make this: when I write: /balance, I see my balance?
  2. Hi, Try this. I hope it helps you (btw i typed it in notepad so i'm sorry if there are any errors)

    Code (Java):
    public class BalanceManager(){

    FileConfiguration configuration = null //<your config here>

    public static void addBalance(Player player, int amount){
    int i = getBalance(player) + amount;
    config.set("balances."+player.getName(), i);

    public static void setBalance(Player player, int newBalance(){

    public static int getBalance(Player player){
    return config.getInt("balances."+player.getName());

    #2 pcrunn, Nov 10, 2018
    Last edited: Nov 10, 2018
    • Funny Funny x 2
  3. Use Vault's economy to retrieve the player's balance.
    • Agree Agree x 2
  4. it would be better off saving the balance into a hashmap then on disable retreive those values and save them in the config.
    • Agree Agree x 1
  5. Or use vault ;-; as the majority of plugins that use economy, use vault.
    • Agree Agree x 1

Share This Page