public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
}
AccountContext account = this.currency.getAccountManager().getAccount(playerName);
if (account == null) {
return new EconomyResponse(0.0, 0.0, ResponseType.FAILURE, "That account does not exist");
} else if (!account.hasBalance(amount)) {
return new EconomyResponse(0.0, account.getBalance(), ResponseType.FAILURE, "Insufficient funds");
} else {
account.subtractBalance(amount);
return new EconomyResponse(amount, account.getBalance(), ResponseType.SUCCESS, "");
}
}