@Override public EconomyResponse bankBalance(String name) { if (!economy.bankExists(name)) { return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!"); } double bankMoney = economy.getBankMoney(name); return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, null); }
@Override public EconomyResponse isBankMember(String name, String playerName) { if (!economy.bankExists(name)) { return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!"); } else if (economy.isBankMember(name, playerName)) { return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, ""); } else return new EconomyResponse(0, 0, ResponseType.FAILURE, "That player is not a bank member!"); }
@Override public EconomyResponse createBank(String name, String player) { boolean success = economy.addBankOwner(name, player, false); if (success) { return new EconomyResponse(0, economy.getBankMoney(name), ResponseType.SUCCESS, ""); } return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to create that bank account."); }
@Override public EconomyResponse bankDeposit(String name, double amount) { if (!economy.bankExists(name)) { return new EconomyResponse(amount, 0, ResponseType.FAILURE, "That bank does not exist!"); } else { economy.addBankMoney(name, (int) amount, true); return new EconomyResponse( (int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, ""); } }
@Override public EconomyResponse bankWithdraw(String name, double amount) { EconomyResponse er = bankHas(name, amount); if (!er.transactionSuccess()) { return er; } else { economy.addBankMoney(name, (int) -amount, true); return new EconomyResponse( (int) amount, economy.getBankMoney(name), ResponseType.SUCCESS, ""); } }
@Override public EconomyResponse bankHas(String name, double amount) { if (!economy.bankExists(name)) { return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!"); } double bankMoney = economy.getBankMoney(name); if (bankMoney < amount) { return new EconomyResponse( 0, bankMoney, ResponseType.FAILURE, "The bank does not have enough money!"); } else { return new EconomyResponse(0, bankMoney, ResponseType.SUCCESS, ""); } }
@SuppressWarnings("deprecation") public double balance() { return Double.valueOf(BOSEconomy.getBankMoney(name)); }