コード例 #1
0
  public void parseAdminUnclaimCommand(String[] split) {

    if (split.length == 1 && split[0].equalsIgnoreCase("?")) {
      for (String line : ta_unclaim) ((CommandSender) getSender()).sendMessage(line);
    } else {

      if (isConsole) {
        sender.sendMessage("[Towny] InputError: This command was designed for use in game only.");
        return;
      }

      try {
        if (TownyUniverse.isWarTime())
          throw new TownyException(TownySettings.getLangString("msg_war_cannot_do"));

        List<WorldCoord> selection;
        selection =
            AreaSelectionUtil.selectWorldCoordArea(
                null, new WorldCoord(player.getWorld().getName(), Coord.parseCoord(player)), split);
        selection = AreaSelectionUtil.filterWildernessBlocks(selection);

        new TownClaim(plugin, player, null, selection, false, false, true).start();

      } catch (TownyException x) {
        TownyMessaging.sendErrorMsg(player, x.getMessage());
        return;
      }
    }
  }
コード例 #2
0
  public void parseToggleCommand(String[] split) throws TownyException {

    boolean choice;

    if (split.length == 0) {
      // command was '/townyadmin toggle'
      player.sendMessage(ChatTools.formatTitle("/townyadmin toggle"));
      player.sendMessage(ChatTools.formatCommand("", "/townyadmin toggle", "war", ""));
      player.sendMessage(ChatTools.formatCommand("", "/townyadmin toggle", "neutral", ""));
      player.sendMessage(ChatTools.formatCommand("", "/townyadmin toggle", "devmode", ""));
      player.sendMessage(ChatTools.formatCommand("", "/townyadmin toggle", "debug", ""));
      player.sendMessage(
          ChatTools.formatCommand("", "/townyadmin toggle", "townwithdraw/nationwithdraw", ""));
      player.sendMessage(ChatTools.formatCommand("", "/townyadmin toggle npc", "[resident]", ""));
      return;
    }

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

    if (split[0].equalsIgnoreCase("war")) {
      choice = TownyUniverse.isWarTime();

      if (!choice) {
        plugin.getTownyUniverse().startWarEvent();
        TownyMessaging.sendMsg(getSender(), TownySettings.getLangString("msg_war_started"));
      } else {
        plugin.getTownyUniverse().endWarEvent();
        TownyMessaging.sendMsg(getSender(), TownySettings.getLangString("msg_war_ended"));
      }
    } else if (split[0].equalsIgnoreCase("neutral")) {

      try {
        choice = !TownySettings.isDeclaringNeutral();
        TownySettings.setDeclaringNeutral(choice);
        TownyMessaging.sendMsg(
            getSender(),
            String.format(
                TownySettings.getLangString("msg_nation_allow_neutral"),
                choice ? "Enabled" : "Disabled"));

      } catch (Exception e) {
        TownyMessaging.sendErrorMsg(
            getSender(), TownySettings.getLangString("msg_err_invalid_choice"));
        return;
      }

    } else if (split[0].equalsIgnoreCase("devmode")) {
      try {
        choice = !TownySettings.isDevMode();
        TownySettings.setDevMode(choice);
        TownyMessaging.sendMsg(
            getSender(),
            "Dev Mode " + (choice ? Colors.Green + "Enabled" : Colors.Red + "Disabled"));
      } catch (Exception e) {
        TownyMessaging.sendErrorMsg(
            getSender(), TownySettings.getLangString("msg_err_invalid_choice"));
      }
    } else if (split[0].equalsIgnoreCase("debug")) {
      try {
        choice = !TownySettings.getDebug();
        TownySettings.setDebug(choice);
        TownyMessaging.sendMsg(
            getSender(),
            "Debug Mode " + (choice ? Colors.Green + "Enabled" : Colors.Red + "Disabled"));
      } catch (Exception e) {
        TownyMessaging.sendErrorMsg(
            getSender(), TownySettings.getLangString("msg_err_invalid_choice"));
      }
    } else if (split[0].equalsIgnoreCase("townwithdraw")) {
      try {
        choice = !TownySettings.getTownBankAllowWithdrawls();
        TownySettings.SetTownBankAllowWithdrawls(choice);
        TownyMessaging.sendMsg(
            getSender(),
            "Town Withdrawls " + (choice ? Colors.Green + "Enabled" : Colors.Red + "Disabled"));
      } catch (Exception e) {
        TownyMessaging.sendErrorMsg(
            getSender(), TownySettings.getLangString("msg_err_invalid_choice"));
      }
    } else if (split[0].equalsIgnoreCase("nationwithdraw")) {
      try {
        choice = !TownySettings.geNationBankAllowWithdrawls();
        TownySettings.SetNationBankAllowWithdrawls(choice);
        TownyMessaging.sendMsg(
            getSender(),
            "Nation Withdrawls " + (choice ? Colors.Green + "Enabled" : Colors.Red + "Disabled"));
      } catch (Exception e) {
        TownyMessaging.sendErrorMsg(
            getSender(), TownySettings.getLangString("msg_err_invalid_choice"));
      }

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

      if (split.length != 2)
        throw new TownyException(
            String.format(
                TownySettings.getLangString("msg_err_invalid_input"), "Eg: toggle npc [resident]"));

      try {
        Resident resident = TownyUniverse.getDataSource().getResident(split[1]);
        resident.setNPC(!resident.isNPC());

        TownyUniverse.getDataSource().saveResident(resident);

        TownyMessaging.sendMessage(
            sender,
            String.format(
                TownySettings.getLangString("msg_npc_flag"), resident.isNPC(), resident.getName()));

      } catch (NotRegisteredException x) {
        throw new TownyException(
            String.format(TownySettings.getLangString("msg_err_not_registered_1"), split[1]));
      }

    } else {
      // parameter error message
      // neutral/war/townmobs/worldmobs
      TownyMessaging.sendErrorMsg(
          getSender(), TownySettings.getLangString("msg_err_invalid_choice"));
    }
  }
コード例 #3
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));
  }