Exemplo n.º 1
0
  public void depositCurrencyBank(String quantity) {
    if (localSender.isConsole()) {
      localSender.notifyConsoleNotSupported();
      return;
    }

    if (!MCTConfig.ECONOMY_ENABLED.getBoolean()) {
      localSender.sendMessage(ERR + "The economy isn't enabled for your server.");
      return;
    }

    BigDecimal amt;
    try {
      amt = new BigDecimal(quantity);
    } catch (NumberFormatException nfe) {
      localSender.sendMessage(
          ERR + "Error parsing quantity \"" + quantity + "\" : " + nfe.getMessage());
      return;
    }

    Town t = localSender.getActiveTown();

    if (t == null) {
      localSender.notifyActiveTownNotSet();
      return;
    }

    EconomyResponse result =
        MCTowns.getEconomy().withdrawPlayer(localSender.getPlayer().getName(), amt.doubleValue());

    if (result.transactionSuccess()) {
      t.getBank().depositCurrency(amt);
      localSender.sendMessage(
          quantity
              + " was withdrawn from your account and deposited into "
              + t.getTownName()
              + "'s town bank.");
    } else {
      localSender.sendMessage(
          ERR + "Transaction failed; maybe you do not have enough money to do this?");
      localSender.sendMessage(ChatColor.GOLD + "Actual amount deposited: " + result.amount);
    }
  }
Exemplo n.º 2
0
  public void withdrawCurrencyBank(String quantity) {
    if (localSender.isConsole()) {
      localSender.notifyConsoleNotSupported();
      return;
    }

    if (!localSender.hasMayoralPermissions()) {
      localSender.notifyInsufPermissions();
      return;
    }

    if (!MCTConfig.ECONOMY_ENABLED.getBoolean()) {
      localSender.sendMessage(ERR + "The economy isn't enabled for your server.");
      return;
    }

    BigDecimal amt;
    try {
      amt = new BigDecimal(quantity);
    } catch (NumberFormatException nfe) {
      localSender.sendMessage(
          ERR + "Error parsing quantity \"" + quantity + "\" : " + nfe.getMessage());
      return;
    }

    Town t = localSender.getActiveTown();

    if (t == null) {
      localSender.notifyActiveTownNotSet();
      return;
    }

    // DO the withdrawl from the town bank
    amt = t.getBank().withdrawCurrency(amt);

    MCTowns.getEconomy().depositPlayer(localSender.getPlayer().getName(), amt.doubleValue());
    localSender.sendMessage(
        amt
            + " was withdrawn from "
            + t.getTownName()
            + "'s town bank and deposited into your account.");
  }