Package net.milkbowl.vault.economy

Examples of net.milkbowl.vault.economy.EconomyResponse


  @Override
  public EconomyResponse deleteBank(String name) {
    boolean success = Common.getInstance().getAccountManager().delete(Account.BANK_PREFIX + name);
    if (success) {
      return new EconomyResponse(0, 0, ResponseType.SUCCESS, "");
    }

    return new EconomyResponse(0, 0, ResponseType.FAILURE, "Unable to delete that bank account.");
  }
View Full Code Here


  public EconomyResponse bankHas(String name, double amount) {

    if (Common.getInstance().getAccountManager().exist(Account.BANK_PREFIX + name)) {
      Account account = Common.getInstance().getAccountManager().getAccount(Account.BANK_PREFIX + name);
      if (account.hasEnough(amount, Common.getInstance().getServerCaller().getDefaultWorld(), Common.getInstance().getCurrencyManager().getDefaultCurrency().getName())) {
        return new EconomyResponse(0, bankBalance(Account.BANK_PREFIX + name).balance, ResponseType.SUCCESS, "");
      } else {
        return new EconomyResponse(0, bankBalance(Account.BANK_PREFIX + name).balance, ResponseType.FAILURE, "The bank does not have enough money!");
      }
    }
    return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
  }
View Full Code Here

  }

  @Override
  public EconomyResponse bankWithdraw(String name, double amount) {
    if (amount < 0) {
      return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot withdraw negative funds");
    }

    EconomyResponse er = bankHas(name, amount);
    if (!er.transactionSuccess()) {
      return er;
    } else {
      if (Common.getInstance().getAccountManager().exist(Account.BANK_PREFIX + name)) {
        return new EconomyResponse(0, withdrawPlayer(Account.BANK_PREFIX + name, amount).balance, ResponseType.SUCCESS, "");
      }
      return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
    }
  }
View Full Code Here

  }

  @Override
  public EconomyResponse bankDeposit(String name, double amount) {
    if (amount < 0) {
      return new EconomyResponse(0, 0, ResponseType.FAILURE, "Cannot desposit negative funds");
    }

    if (Common.getInstance().getAccountManager().exist(Account.BANK_PREFIX + name)) {
      return new EconomyResponse(0, depositPlayer(Account.BANK_PREFIX + name, amount).balance, ResponseType.SUCCESS, "");
    }
    return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
  }
View Full Code Here

  @Override
  public EconomyResponse isBankOwner(String name, String playerName) {
    if (Common.getInstance().getAccountManager().exist(Account.BANK_PREFIX + name)) {
      if (Common.getInstance().getAccountManager().getAccount(Account.BANK_PREFIX + name).getAccountACL().isOwner(playerName)) {
        return new EconomyResponse(0, bankBalance(Account.BANK_PREFIX + name).balance, ResponseType.SUCCESS, "");
      }
      return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not the owner of the bank!");
    }
    return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
  }
View Full Code Here

  @Override
  public EconomyResponse isBankMember(String name, String playerName) {

    // Basicly here if the user have access to deposit & withdraw he's a member
    EconomyResponse er = isBankOwner(name, playerName);
    if (er.transactionSuccess()) {
      return er;
    } else {
      if (Common.getInstance().getAccountManager().exist(Account.BANK_PREFIX + name)) {
        Account account = Common.getInstance().getAccountManager().getAccount(Account.BANK_PREFIX + name);
        if (account.getAccountACL().canDeposit(playerName) && account.getAccountACL().canWithdraw(playerName)) {
          return new EconomyResponse(0, bankBalance(name).balance, ResponseType.SUCCESS, "");
        }
      }
      return new EconomyResponse(0, 0, ResponseType.FAILURE, "This player is not a member of the bank!");
    }
  }
View Full Code Here

  }

  @Override
  public EconomyResponse bankBalance(String name) {
    if (Common.getInstance().getAccountManager().exist(Account.BANK_PREFIX + name)) {
      return new EconomyResponse(0, getBalance(Account.BANK_PREFIX + name), ResponseType.SUCCESS, "");
    }
    return new EconomyResponse(0, 0, ResponseType.FAILURE, "That bank does not exist!");
  }
View Full Code Here

  }

  @Override
  public EconomyResponse withdrawPlayer(String playerName, String worldName, double amount) {
    if (amount < 0) {
      return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Cannot withdraw negative funds");
    }

    double balance;
    Account account = Common.getInstance().getAccountManager().getAccount(playerName);
    if (account.hasEnough(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName())) {
      balance = account.withdraw(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName(), Cause.VAULT, null);
      return new EconomyResponse(amount, balance, ResponseType.SUCCESS, "");
    } else {
      return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Insufficient funds");
    }
  }
View Full Code Here

  }

  @Override
  public EconomyResponse depositPlayer(String playerName, String worldName, double amount) {
    if (amount < 0) {
      return new EconomyResponse(0, getBalance(playerName, worldName), ResponseType.FAILURE, "Cannot desposit negative funds");
    }

    Account account = Common.getInstance().getAccountManager().getAccount(playerName);

    double balance = account.deposit(amount, worldName, Common.getInstance().getCurrencyManager().getDefaultCurrency().getName(), Cause.VAULT, null);
    return new EconomyResponse(amount, balance, ResponseType.SUCCESS, null);
  }
View Full Code Here

    } else {
      rt = ResponseType.FAILURE;
      message = "Not enough money";
    }
   
    return new EconomyResponse(amount, Economy.getBalance(playerName), rt, message);
  }
View Full Code Here

TOP

Related Classes of net.milkbowl.vault.economy.EconomyResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.