package cc.lukatown.icefox.plugincore.Functions;

import cc.lukatown.icefox.plugincore.PluginCore;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.entity.Player;

/**
 * *******************************************
 * Created by MXD on 14-10-12.
 * for 2dmmc
 * E-mail : i@mxd.moe
 * ********************************************
 */
public class PluginCoreFunction_Money {
    static Economy eco = PluginCore.economy;

    public static double getPlayerMoney(Player player) {
        return eco.getBalance(player.getName());
    }

    public static String withdrawPlayerMoney(Player player, double money) {
        EconomyResponse economyResponse;

        economyResponse = eco.withdrawPlayer(player.getName(), money);
        if (economyResponse.transactionSuccess()) {
            return "done";
        } else {
            return economyResponse.errorMessage;
        }
    }

    public static String depositPlayerMoney(Player player, double money) {
        EconomyResponse economyResponse;

        economyResponse = eco.depositPlayer(player.getName(), money);
        if (economyResponse.transactionSuccess()) {
            return "done";
        } else {
            return economyResponse.errorMessage;
        }
    }
}
