Ejemplo n.º 1
0
  private void buildTAPanel() {

    ta_panel.clear();
    Runtime run = Runtime.getRuntime();
    ta_panel.add(ChatTools.formatTitle(TownySettings.getLangString("ta_panel_1")));
    ta_panel.add(
        Colors.Blue
            + "["
            + Colors.LightBlue
            + "Towny"
            + Colors.Blue
            + "] "
            + Colors.Green
            + TownySettings.getLangString("ta_panel_2")
            + Colors.LightGreen
            + TownyUniverse.isWarTime()
            + Colors.Gray
            + " | "
            + Colors.Green
            + TownySettings.getLangString("ta_panel_3")
            + (TownyTimerHandler.isHealthRegenRunning()
                ? Colors.LightGreen + "On"
                : Colors.Rose + "Off")
            + Colors.Gray
            + " | "
            + (Colors.Green
                + TownySettings.getLangString("ta_panel_5")
                + (TownyTimerHandler.isDailyTimerRunning()
                    ? Colors.LightGreen + "On"
                    : Colors.Rose + "Off")));
    /*
     * ta_panel.add(Colors.Blue + "[" + Colors.LightBlue + "Towny" +
     * Colors.Blue + "] " + Colors.Green +
     * TownySettings.getLangString("ta_panel_4") +
     * (TownySettings.isRemovingWorldMobs() ? Colors.LightGreen + "On" :
     * Colors.Rose + "Off") + Colors.Gray + " | " + Colors.Green +
     * TownySettings.getLangString("ta_panel_4_1") +
     * (TownySettings.isRemovingTownMobs() ? Colors.LightGreen + "On" :
     * Colors.Rose + "Off"));
     *
     * try { TownyEconomyObject.checkEconomy(); ta_panel.add(Colors.Blue +
     * "[" + Colors.LightBlue + "Economy" + Colors.Blue + "] " +
     * Colors.Green + TownySettings.getLangString("ta_panel_6") +
     * Colors.LightGreen + TownyFormatter.formatMoney(getTotalEconomy()) +
     * Colors.Gray + " | " + Colors.Green +
     * TownySettings.getLangString("ta_panel_7") + Colors.LightGreen +
     * getNumBankAccounts()); } catch (Exception e) { }
     */
    ta_panel.add(
        Colors.Blue
            + "["
            + Colors.LightBlue
            + TownySettings.getLangString("ta_panel_8")
            + Colors.Blue
            + "] "
            + Colors.Green
            + TownySettings.getLangString("ta_panel_9")
            + Colors.LightGreen
            + MemMgmt.getMemSize(run.totalMemory())
            + Colors.Gray
            + " | "
            + Colors.Green
            + TownySettings.getLangString("ta_panel_10")
            + Colors.LightGreen
            + Thread.getAllStackTraces().keySet().size()
            + Colors.Gray
            + " | "
            + Colors.Green
            + TownySettings.getLangString("ta_panel_11")
            + Colors.LightGreen
            + TownyFormatter.getTime());
    ta_panel.add(Colors.Yellow + MemMgmt.getMemoryBar(50, run));
  }
Ejemplo n.º 2
0
  public boolean parseTownyAdminCommand(String[] split) throws TownyException {

    if (split.length == 0) {
      buildTAPanel();
      for (String line : ta_panel) {
        sender.sendMessage(line);
      }

    } else if (split[0].equalsIgnoreCase("?") || split[0].equalsIgnoreCase("help")) {
      for (String line : ta_help) {
        sender.sendMessage(line);
      }
    } else {

      if (split[0].equalsIgnoreCase("set")) {

        adminSet(StringMgmt.remFirstArg(split));
        return true;

      } else if (split[0].equalsIgnoreCase("town")) {

        parseAdminTownCommand(StringMgmt.remFirstArg(split));
        return true;

      } else if (split[0].equalsIgnoreCase("nation")) {

        parseAdminNationCommand(StringMgmt.remFirstArg(split));
        return true;

      } else if (split[0].equalsIgnoreCase("toggle")) {

        parseToggleCommand(StringMgmt.remFirstArg(split));
        return true;
      }

      if ((!isConsole)
          && (!TownyUniverse.getPermissionSource()
              .testPermission(
                  player,
                  PermissionNodes.TOWNY_COMMAND_TOWNYADMIN.getNode(split[0].toLowerCase()))))
        throw new TownyException(TownySettings.getLangString("msg_err_command_disable"));

      if (split[0].equalsIgnoreCase("givebonus")) {

        giveBonus(StringMgmt.remFirstArg(split));

      } else if (split[0].equalsIgnoreCase("reload")) {

        reloadTowny(false);

      } else if (split[0].equalsIgnoreCase("reset")) {

        reloadTowny(true);

      } else if (split[0].equalsIgnoreCase("backup")) {

        try {
          TownyUniverse.getDataSource().backup();
          TownyMessaging.sendMsg(getSender(), TownySettings.getLangString("mag_backup_success"));

        } catch (IOException e) {
          TownyMessaging.sendErrorMsg(getSender(), "Error: " + e.getMessage());
        }

      } else if (split[0].equalsIgnoreCase("newday")) {

        TownyTimerHandler.newDay();

      } else if (split[0].equalsIgnoreCase("purge")) {

        purge(StringMgmt.remFirstArg(split));

      } else if (split[0].equalsIgnoreCase("delete")) {
        String[] newSplit = StringMgmt.remFirstArg(split);
        residentDelete(player, newSplit);
      } else if (split[0].equalsIgnoreCase("unclaim")) {

        parseAdminUnclaimCommand(StringMgmt.remFirstArg(split));
        /*
         * else if (split[0].equalsIgnoreCase("seed") &&
         * TownySettings.getDebug()) seedTowny(); else if
         * (split[0].equalsIgnoreCase("warseed") &&
         * TownySettings.getDebug()) warSeed(player);
         */

      } else {
        TownyMessaging.sendErrorMsg(
            getSender(), TownySettings.getLangString("msg_err_invalid_sub"));
        return false;
      }
    }

    return true;
  }