public BOSEAdapter(BOSEconomy p) { plugin = p; String serverland = Residence.getServerLandname(); if (!plugin.playerRegistered(serverland, false)) { plugin.registerPlayer(serverland); } }
@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); } }
@Override public boolean createPlayerAccount(String playerName) { if (economy.playerRegistered(playerName, false)) { return false; } return economy.registerPlayer(playerName); }
public String format(double amount) { String currency = BOSEconomy.getMoneyNamePlural(); if (amount == 1) { currency = BOSEconomy.getMoneyName(); } return amount + " " + currency; }
@Override public boolean subtract(String playerName, double amount) { if (canAfford(playerName, amount)) { return plugin.setPlayerMoney( playerName, plugin.getPlayerMoneyDouble(playerName) - amount, false); } return false; }
@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 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 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, ""); } }
@Override public EconomyResponse deleteBank(String name) { boolean success = economy.removeBank(name); if (success) { return new EconomyResponse(0, 0, ResponseType.SUCCESS, ""); } return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to remove that bank account."); }
@Override public boolean isEnabled() { if (economy == null) { return false; } else { return economy.isEnabled(); } }
@Override public boolean canAfford(String playerName, double amount) { double balance = plugin.getPlayerMoneyDouble(playerName); if (balance >= amount) { return true; } return false; }
@Override public double getBalance(String playerName) { return (double) economy.getPlayerMoney(playerName); }
public boolean remove() { return BOSEconomy.removeBank(bank); }
@SuppressWarnings("deprecation") public boolean divide(double amount) { int IntAmount = (int) Math.ceil(amount); int balance = (int) balance(); return BOSEconomy.setBankMoney(name, (balance / IntAmount), false); }
@SuppressWarnings("deprecation") public boolean set(double amount) { int IntAmount = (int) Math.ceil(amount); return BOSEconomy.setBankMoney(name, IntAmount, true); }
@Override public List<String> getBanks() { return economy.getBankList(); }
@Override public boolean add(String playerName, double amount) { return plugin.setPlayerMoney( playerName, plugin.getPlayerMoneyDouble(playerName) + amount, false); }
@Override public boolean hasAccount(String playerName) { return economy.playerRegistered(playerName, false); }
@SuppressWarnings("deprecation") public boolean add(double amount) { int IntAmount = (int) Math.ceil(amount); return BOSEconomy.addPlayerMoney(name, IntAmount, false); }
public boolean hasBankAccount(String bank, String name) { return BOSEconomy.isBankOwner(bank, name); }
public boolean hasBank(String bank) { return BOSEconomy.bankExists(bank); }
public boolean hasAccount(String name) { return BOSEconomy.playerRegistered(name, false); }
@Override public String currencyNamePlural() { return economy.getMoneyNamePlural(); }
@SuppressWarnings("deprecation") public double balance() { return Double.valueOf(BOSEconomy.getPlayerMoney(name)); }
@Override public double getBalance(String playerName) { return plugin.getPlayerMoneyDouble(playerName); }
@SuppressWarnings("deprecation") public boolean subtract(double amount) { int IntAmount = (int) Math.ceil(amount); int balance = (int) balance(); return BOSEconomy.setPlayerMoney(name, (balance - IntAmount), false); }
@Override public String currencyNameSingular() { return economy.getMoneyName(); }