@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 = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName); return new EconomyResponse(amount, balance, type, errorMessage); } if (CurrencyList.add(playerName, amount)) { type = EconomyResponse.ResponseType.SUCCESS; balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName); return new EconomyResponse(amount, balance, type, errorMessage); } else { errorMessage = "Error withdrawing funds"; type = EconomyResponse.ResponseType.FAILURE; amount = 0; balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName); return new EconomyResponse(amount, balance, type, errorMessage); } }
@Override public double getBalance(String playerName) { final double balance; balance = CurrencyList.getValue((String) CurrencyList.maxCurrency(playerName)[0], playerName); final double fBalance = balance; return fBalance; }