Exemple #1
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);
    }
  }
Exemple #2
0
 @Override
 public boolean subtract(String playerName, double amount) {
   if (canAfford(playerName, amount)) {
     return plugin.setPlayerMoney(
         playerName, plugin.getPlayerMoneyDouble(playerName) - amount, false);
   }
   return false;
 }
Exemple #3
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);
 }
Exemple #4
0
 @SuppressWarnings("deprecation")
 public boolean set(double amount) {
   int IntAmount = (int) Math.ceil(amount);
   return BOSEconomy.setPlayerMoney(name, IntAmount, false);
 }
Exemple #5
0
 @Override
 public boolean add(String playerName, double amount) {
   return plugin.setPlayerMoney(
       playerName, plugin.getPlayerMoneyDouble(playerName) + amount, false);
 }