}
@Override
public EconomyResponse withdrawPlayer(String playerName, double amount) {
if (amount < 0) {
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Cannot withdraw negative funds");
}
if (!has(playerName, amount)) {
return new EconomyResponse(0, economy.getPlayerMoneyDouble(playerName), ResponseType.FAILURE, "Insufficient funds");
}
double balance = economy.getPlayerMoneyDouble(playerName);
if (economy.setPlayerMoney(playerName, balance - amount, false)) {
balance = economy.getPlayerMoneyDouble(playerName);
return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
} else {
return new EconomyResponse(0, balance, ResponseType.FAILURE, "Error withdrawing funds");
}
}