@Override public EconomyResponse depositPlayer(String playerName, double amount) { double balance; EconomyResponse.ResponseType type; String errorMessage = null; if (amount < 0) { errorMessage = "Cannot deposit negative funds"; type = EconomyResponse.ResponseType.FAILURE; amount = 0; balance = (double) economy.getPlayerMoney(playerName); return new EconomyResponse(balance, balance, type, errorMessage); } amount = Math.ceil(amount); balance = (double) economy.getPlayerMoney(playerName); if (economy.setPlayerMoney(playerName, (int) (balance + amount), false)) { type = EconomyResponse.ResponseType.SUCCESS; balance = (double) economy.getPlayerMoney(playerName); return new EconomyResponse(amount, balance, type, errorMessage); } else { errorMessage = "Error withdrawing funds"; type = EconomyResponse.ResponseType.FAILURE; amount = 0; balance = (double) economy.getPlayerMoney(playerName); return new EconomyResponse(balance, balance, type, errorMessage); } }
@SuppressWarnings("deprecation") public double balance() { return Double.valueOf(BOSEconomy.getPlayerMoney(name)); }
@Override public double getBalance(String playerName) { return (double) economy.getPlayerMoney(playerName); }