private void listCharacters(L2PcInstance activeChar, int page) {
    Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers().values();
    L2PcInstance[] players;
    // synchronized (L2World.getInstance().getAllPlayers())
    {
      players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
    }

    int maxCharactersPerPage = 20;
    int maxPages = players.length / maxCharactersPerPage;

    if (players.length > maxCharactersPerPage * maxPages) maxPages++;

    // Check if number of users changed
    if (page > maxPages) page = maxPages;

    int charactersStart = maxCharactersPerPage * page;
    int charactersEnd = players.length;
    if (charactersEnd - charactersStart > maxCharactersPerPage)
      charactersEnd = charactersStart + maxCharactersPerPage;

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/charlist.htm");

    final StringBuilder replyMSG = new StringBuilder(1000);

    for (int x = 0; x < maxPages; x++) {
      int pagenr = x + 1;
      StringUtil.append(
          replyMSG,
          "<center><a action=\"bypass -h admin_show_characters "
              + x
              + "\">"
              + MessageTable.Messages[677].getMessage()
              + pagenr
              + MessageTable.Messages[215].getMessage()
              + "</a></center>");
    }

    adminReply.replace("%pages%", replyMSG.toString());
    replyMSG.setLength(0);

    for (int i = charactersStart; i < charactersEnd; i++) {
      // Add player info into new Table row
      StringUtil.append(
          replyMSG,
          "<tr><td width=80><a action=\"bypass -h admin_character_info ",
          players[i].getName(),
          "\">",
          players[i].getName(),
          "</a></td><td width=110>",
          players[i].getTemplate().className,
          "</td><td width=40>",
          String.valueOf(players[i].getLevel()),
          "</td></tr>");
    }

    adminReply.replace("%players%", replyMSG.toString());
    activeChar.sendPacket(adminReply);
  }
  private void showFortSelectPage(L2PcInstance activeChar) {
    int i = 0;
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/forts.htm");

    final List<Fort> forts = FortManager.getInstance().getForts();
    final StringBuilder cList = new StringBuilder(forts.size() * 100);

    for (Fort fort : forts) {
      if (fort != null) {
        StringUtil.append(
            cList,
            "<td fixwidth=90><a action=\"bypass -h admin_fortsiege ",
            String.valueOf(fort.getFortId()),
            "\">",
            fort.getName(),
            " ID: ", // Update by rocknow
            String.valueOf(fort.getFortId()),
            "</a></td>");
        i++;
      }

      if (i > 0) { // Update by rocknow
        cList.append("</tr><tr>");
        i = 0;
      }
    }

    adminReply.replace("%forts%", cList.toString());
    activeChar.sendPacket(adminReply);
  }
  /**
   * @param activeChar
   * @throws IllegalArgumentException
   */
  private void findDualbox(L2PcInstance activeChar, int multibox) throws IllegalArgumentException {
    Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers().values();
    L2PcInstance[] players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);

    Map<String, List<L2PcInstance>> ipMap = new HashMap<String, List<L2PcInstance>>();

    String ip = "0.0.0.0";
    L2GameClient client;

    final Map<String, Integer> dualboxIPs = new HashMap<String, Integer>();

    for (L2PcInstance player : players) {
      client = player.getClient();
      if (client.isDetached()) continue;
      else {
        ip = client.getConnection().getInetAddress().getHostAddress();
        if (ipMap.get(ip) == null) ipMap.put(ip, new ArrayList<L2PcInstance>());
        ipMap.get(ip).add(player);

        if (ipMap.get(ip).size() >= multibox) {
          Integer count = dualboxIPs.get(ip);
          if (count == null) dualboxIPs.put(ip, multibox);
          else dualboxIPs.put(ip, count + 1);
        }
      }
    }

    List<String> keys = new ArrayList<String>(dualboxIPs.keySet());
    Collections.sort(
        keys,
        new Comparator<String>() {
          public int compare(String left, String right) {
            return dualboxIPs.get(left).compareTo(dualboxIPs.get(right));
          }
        });
    Collections.reverse(keys);

    final StringBuilder results = new StringBuilder();
    for (String dualboxIP : keys) {
      StringUtil.append(
          results,
          "<a action=\"bypass -h admin_find_ip "
              + dualboxIP
              + "\">"
              + dualboxIP
              + " ("
              + dualboxIPs.get(dualboxIP)
              + ")</a><br1>");
    }

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/dualbox.htm");
    adminReply.replace("%multibox%", String.valueOf(multibox));
    adminReply.replace("%results%", results.toString());
    activeChar.sendPacket(adminReply);
  }
  /**
   * @param activeChar
   * @param CharacterToFind
   */
  private void findCharacter(L2PcInstance activeChar, String CharacterToFind) {
    int CharactersFound = 0;
    String name;
    Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers().values();
    L2PcInstance[] players;
    // synchronized (L2World.getInstance().getAllPlayers())
    {
      players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
    }
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/charfind.htm");

    final StringBuilder replyMSG = new StringBuilder(1000);

    for (L2PcInstance player : players) { // Add player info into new Table row
      name = player.getName();
      if (name.toLowerCase().contains(CharacterToFind.toLowerCase())) {
        CharactersFound = CharactersFound + 1;
        StringUtil.append(
            replyMSG,
            "<tr><td width=80><a action=\"bypass -h admin_character_list ",
            name,
            "\">",
            name,
            "</a></td><td width=110>",
            player.getTemplate().className,
            "</td><td width=40>",
            String.valueOf(player.getLevel()),
            "</td></tr>");
      }
      if (CharactersFound > 20) break;
    }
    adminReply.replace("%results%", replyMSG.toString());

    final String replyMSG2;

    if (CharactersFound == 0) {
      replyMSG2 = MessageTable.Messages[678].getMessage();
    } else if (CharactersFound > 20) {
      adminReply.replace("%number%", MessageTable.Messages[679].getMessage());
      replyMSG2 = MessageTable.Messages[680].getMessage();
    } else if (CharactersFound == 1) {
      replyMSG2 = MessageTable.Messages[1196].getMessage();
    } else {
      replyMSG2 = MessageTable.Messages[1197].getMessage();
    }

    adminReply.replace("%number%", String.valueOf(CharactersFound));
    adminReply.replace("%end%", replyMSG2);
    activeChar.sendPacket(adminReply);
  }
  /**
   * @param activeChar
   * @param characterName
   * @throws IllegalArgumentException
   */
  private void findCharactersPerAccount(L2PcInstance activeChar, String characterName)
      throws IllegalArgumentException {
    if (characterName.matches(Config.CNAME_TEMPLATE)) {
      String account = null;
      Map<Integer, String> chars;
      L2PcInstance player = L2World.getInstance().getPlayer(characterName);
      if (player == null) throw new IllegalArgumentException("Player doesn't exist");
      chars = player.getAccountChars();
      account = player.getAccountName();
      final StringBuilder replyMSG = new StringBuilder(chars.size() * 20);
      NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
      adminReply.setFile("data/html/admin/accountinfo.htm");
      for (String charname : chars.values()) {
        StringUtil.append(replyMSG, charname, "<br1>");
      }

      adminReply.replace("%characters%", replyMSG.toString());
      adminReply.replace("%account%", account);
      adminReply.replace("%player%", characterName);
      activeChar.sendPacket(adminReply);
    } else throw new IllegalArgumentException("Malformed character name");
  }
  /**
   * @param activeChar
   * @param IpAdress
   * @throws IllegalArgumentException
   */
  private void findCharactersPerIp(L2PcInstance activeChar, String IpAdress)
      throws IllegalArgumentException {
    boolean findDisconnected = false;

    if (IpAdress.equals("disconnected")) {
      findDisconnected = true;
    } else {
      if (!IpAdress.matches(
          "^(?:(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2(?:[0-4][0-9]|5[0-5]))$"))
        throw new IllegalArgumentException("Malformed IPv4 number");
    }
    Collection<L2PcInstance> allPlayers = L2World.getInstance().getAllPlayers().values();
    L2PcInstance[] players;
    // synchronized (L2World.getInstance().getAllPlayers())
    {
      players = allPlayers.toArray(new L2PcInstance[allPlayers.size()]);
    }
    int CharactersFound = 0;
    L2GameClient client;
    String name, ip = "0.0.0.0";
    final StringBuilder replyMSG = new StringBuilder(1000);
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/ipfind.htm");
    for (L2PcInstance player : players) {
      client = player.getClient();
      if (client.isDetached()) {
        if (!findDisconnected) {
          continue;
        }
      } else {
        if (findDisconnected) {
          continue;
        } else {
          ip = client.getConnection().getInetAddress().getHostAddress();
          if (!ip.equals(IpAdress)) continue;
        }
      }

      name = player.getName();
      CharactersFound = CharactersFound + 1;
      StringUtil.append(
          replyMSG,
          "<tr><td width=80><a action=\"bypass -h admin_character_list ",
          name,
          "\">",
          name,
          "</a></td><td width=110>",
          player.getTemplate().className,
          "</td><td width=40>",
          String.valueOf(player.getLevel()),
          "</td></tr>");

      if (CharactersFound > 20) break;
    }
    adminReply.replace("%results%", replyMSG.toString());

    final String replyMSG2;

    if (CharactersFound == 0) {
      replyMSG2 = MessageTable.Messages[681].getMessage();
    } else if (CharactersFound > 20) {
      adminReply.replace(
          "%number%", MessageTable.Messages[1213].getMessage() + String.valueOf(CharactersFound));
      replyMSG2 = MessageTable.Messages[682].getMessage();
    } else if (CharactersFound == 1) {
      replyMSG2 = MessageTable.Messages[1196].getMessage();
    } else {
      replyMSG2 = MessageTable.Messages[1197].getMessage();
    }
    adminReply.replace("%ip%", ip);
    adminReply.replace("%number%", String.valueOf(CharactersFound));
    adminReply.replace("%end%", replyMSG2);
    activeChar.sendPacket(adminReply);
  }