Example #1
0
 public BOSEAdapter(BOSEconomy p) {
   plugin = p;
   String serverland = Residence.getServerLandname();
   if (!plugin.playerRegistered(serverland, false)) {
     plugin.registerPlayer(serverland);
   }
 }
Example #2
0
  @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);
    }
  }
Example #3
0
 @Override
 public boolean createPlayerAccount(String playerName) {
   if (economy.playerRegistered(playerName, false)) {
     return false;
   }
   return economy.registerPlayer(playerName);
 }
Example #4
0
 public String format(double amount) {
   String currency = BOSEconomy.getMoneyNamePlural();
   if (amount == 1) {
     currency = BOSEconomy.getMoneyName();
   }
   return amount + " " + currency;
 }
Example #5
0
 @Override
 public boolean subtract(String playerName, double amount) {
   if (canAfford(playerName, amount)) {
     return plugin.setPlayerMoney(
         playerName, plugin.getPlayerMoneyDouble(playerName) - amount, false);
   }
   return false;
 }
Example #6
0
  @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.");
  }
Example #7
0
  @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);
  }
Example #8
0
 @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!");
 }
Example #9
0
 @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, "");
   }
 }
Example #10
0
 @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, "");
   }
 }
Example #11
0
  @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, "");
    }
  }
Example #12
0
 @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.");
 }
Example #13
0
 @Override
 public boolean isEnabled() {
   if (economy == null) {
     return false;
   } else {
     return economy.isEnabled();
   }
 }
Example #14
0
 @Override
 public boolean canAfford(String playerName, double amount) {
   double balance = plugin.getPlayerMoneyDouble(playerName);
   if (balance >= amount) {
     return true;
   }
   return false;
 }
Example #15
0
 @Override
 public double getBalance(String playerName) {
   return (double) economy.getPlayerMoney(playerName);
 }
Example #16
0
 public boolean remove() {
   return BOSEconomy.removeBank(bank);
 }
Example #17
0
 @SuppressWarnings("deprecation")
 public boolean divide(double amount) {
   int IntAmount = (int) Math.ceil(amount);
   int balance = (int) balance();
   return BOSEconomy.setBankMoney(name, (balance / IntAmount), false);
 }
Example #18
0
 @SuppressWarnings("deprecation")
 public boolean set(double amount) {
   int IntAmount = (int) Math.ceil(amount);
   return BOSEconomy.setBankMoney(name, IntAmount, true);
 }
Example #19
0
 @Override
 public List<String> getBanks() {
   return economy.getBankList();
 }
Example #20
0
 @Override
 public boolean add(String playerName, double amount) {
   return plugin.setPlayerMoney(
       playerName, plugin.getPlayerMoneyDouble(playerName) + amount, false);
 }
Example #21
0
 @Override
 public boolean hasAccount(String playerName) {
   return economy.playerRegistered(playerName, false);
 }
Example #22
0
 @SuppressWarnings("deprecation")
 public boolean add(double amount) {
   int IntAmount = (int) Math.ceil(amount);
   return BOSEconomy.addPlayerMoney(name, IntAmount, false);
 }
Example #23
0
 public boolean hasBankAccount(String bank, String name) {
   return BOSEconomy.isBankOwner(bank, name);
 }
Example #24
0
 public boolean hasBank(String bank) {
   return BOSEconomy.bankExists(bank);
 }
Example #25
0
 public boolean hasAccount(String name) {
   return BOSEconomy.playerRegistered(name, false);
 }
Example #26
0
 @Override
 public String currencyNamePlural() {
   return economy.getMoneyNamePlural();
 }
Example #27
0
 @SuppressWarnings("deprecation")
 public double balance() {
   return Double.valueOf(BOSEconomy.getPlayerMoney(name));
 }
Example #28
0
 @Override
 public double getBalance(String playerName) {
   return plugin.getPlayerMoneyDouble(playerName);
 }
Example #29
0
 @SuppressWarnings("deprecation")
 public boolean subtract(double amount) {
   int IntAmount = (int) Math.ceil(amount);
   int balance = (int) balance();
   return BOSEconomy.setPlayerMoney(name, (balance - IntAmount), false);
 }
Example #30
0
 @Override
 public String currencyNameSingular() {
   return economy.getMoneyName();
 }