Ejemplo n.º 1
0
  public void setDefaultPlotPrice(String plotPrice) {
    if (localSender.isConsole()) {
      localSender.notifyConsoleNotSupported();
      return;
    }

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

    Town t = localSender.getActiveTown();

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

    BigDecimal price;

    try {
      price = new BigDecimal(plotPrice);
    } catch (NumberFormatException nfe) {
      localSender.sendMessage(ERR + "Error parsing plot price: " + nfe.getMessage());
      return;
    }

    t.setDefaultPlotPrice(price);
    localSender.sendMessage(
        SUCC + "The default price of plots in " + t.getTownName() + " has been set to " + price);
  }
Ejemplo n.º 2
0
  public void listResidents(String s_page) {
    if (localSender.isConsole()) {
      localSender.notifyConsoleNotSupported();
      return;
    }

    int i;
    try {
      i = Integer.parseInt(s_page);
    } catch (NumberFormatException ex) {
      localSender.sendMessage(ERR + "Error parsing token \"" + s_page + "\":" + ex.getMessage());
      return;
    }

    listResidents(i);
  }
Ejemplo n.º 3
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);
    }
  }
Ejemplo n.º 4
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.");
  }