private void showFortSiegePage(L2PcInstance activeChar, Fort fort) {
   NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
   adminReply.setFile("data/html/admin/fort.htm");
   adminReply.replace("%fortName%", fort.getName());
   adminReply.replace("%fortId%", String.valueOf(fort.getFortId()));
   activeChar.sendPacket(adminReply);
 }
  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);
  }
Beispiel #3
0
 private static void showPage3(L2PcInstance activeChar, String format, String command) {
   NpcHtmlMessage adminReply = new NpcHtmlMessage(0);
   adminReply.setFile("data/html/admin/pforge3.htm");
   adminReply.replace("%format%", format);
   adminReply.replace("%command%", command);
   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);
  }
Beispiel #5
0
  private static void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall) {
    final L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());

    final NpcHtmlMessage html = new NpcHtmlMessage(0);
    html.setFile("data/html/admin/clanhall.htm");
    html.replace("%clanhallName%", clanhall.getName());
    html.replace("%clanhallId%", clanhall.getId());
    html.replace("%clanhallOwner%", (owner == null) ? "None" : owner.getName());
    activeChar.sendPacket(html);
  }
  /**
   * @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);
  }
Beispiel #7
0
  private static void showPage2(L2PcInstance activeChar, String format) {
    NpcHtmlMessage adminReply = new NpcHtmlMessage(0);
    adminReply.setFile("data/html/admin/pforge2.htm");
    adminReply.replace("%format%", format);

    StringBuilder replyMSG = new StringBuilder();
    for (int i = 0; i < format.length(); i++)
      replyMSG.append(format.charAt(i) + " : <edit var=\"v" + i + "\" width=100><br1>");
    adminReply.replace("%valueditors%", replyMSG.toString());
    replyMSG.setLength(0);

    for (int i = 0; i < format.length(); i++) replyMSG.append(" \\$v" + i);
    adminReply.replace("%send%", 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
   * @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");
  }
Beispiel #10
0
  public void giveBlessingSupport(L2PcInstance player) {
    if (player == null) return;

    // Select the player
    setTarget(player);

    // If the player is too high level, display a message and return
    if (player.getLevel() > 39 || player.getClassId().level() >= 2) {
      NpcHtmlMessage npcReply = new NpcHtmlMessage(getObjectId());
      npcReply.setHtml(
          "<html><body>Newbie Guide:<br>I'm sorry, but you are not eligible to receive the protection blessing.<br1>It can only be bestowed on <font color=\"LEVEL\">characters below level 39 who have not made a seccond transfer.</font></body></html>");
      npcReply.replace("%objectId%", getObjectId());
      player.sendPacket(npcReply);
      return;
    }
    doCast(FrequentSkill.BLESSING_OF_PROTECTION.getSkill());
  }
Beispiel #11
0
  private static void showHtml(L2PcInstance activeChar) {
    int worldX = activeChar.getX();
    int worldY = activeChar.getY();
    int geoX = ((((worldX - (-327680)) >> 4) >> 11) + 10);
    int geoY = ((((worldY - (-262144)) >> 4) >> 11) + 10);

    NpcHtmlMessage adminReply = new NpcHtmlMessage(0);
    adminReply.setFile("data/html/admin/zone.htm");

    adminReply.replace(
        "%MAPREGION%",
        "[x:"
            + MapRegionTable.getMapRegionX(activeChar.getX())
            + " y:"
            + MapRegionTable.getMapRegionX(activeChar.getY())
            + "]");
    adminReply.replace("%GEOREGION%", "" + geoX + "_" + geoY);
    adminReply.replace(
        "%CLOSESTTOWN%", MapRegionTable.getInstance().getClosestTownName(activeChar));
    adminReply.replace(
        "%CURRENTLOC%",
        "" + activeChar.getX() + ", " + activeChar.getY() + ", " + activeChar.getZ());

    adminReply.replace(
        "%PVP%", (activeChar.isInsideZone(ZoneId.PVP) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%PEACE%",
        (activeChar.isInsideZone(ZoneId.PEACE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%SIEGE%",
        (activeChar.isInsideZone(ZoneId.SIEGE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%MOTHERTREE%",
        (activeChar.isInsideZone(ZoneId.MOTHER_TREE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%CLANHALL%",
        (activeChar.isInsideZone(ZoneId.CLAN_HALL) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%NOLANDING%",
        (activeChar.isInsideZone(ZoneId.NO_LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%WATER%",
        (activeChar.isInsideZone(ZoneId.WATER) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%JAIL%",
        (activeChar.isInsideZone(ZoneId.JAIL) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%MONSTERTRACK%",
        (activeChar.isInsideZone(ZoneId.MONSTER_TRACK)
            ? "<font color=\"LEVEL\">YES</font>"
            : "NO"));
    adminReply.replace(
        "%CASTLE%",
        (activeChar.isInsideZone(ZoneId.CASTLE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%SWAMP%",
        (activeChar.isInsideZone(ZoneId.SWAMP) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%NOSUMMONFRIEND%",
        (activeChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND)
            ? "<font color=\"LEVEL\">YES</font>"
            : "NO"));
    adminReply.replace(
        "%NOSTORE%",
        (activeChar.isInsideZone(ZoneId.NO_STORE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%TOWN%",
        (activeChar.isInsideZone(ZoneId.TOWN) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%HQ%", (activeChar.isInsideZone(ZoneId.HQ) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%DANGERAREA%",
        (activeChar.isInsideZone(ZoneId.DANGER_AREA) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
    adminReply.replace(
        "%CASTONARTIFACT%",
        (activeChar.isInsideZone(ZoneId.CAST_ON_ARTIFACT)
            ? "<font color=\"LEVEL\">YES</font>"
            : "NO"));
    adminReply.replace(
        "%NORESTART%",
        (activeChar.isInsideZone(ZoneId.NO_RESTART) ? "<font color=\"LEVEL\">YES</font>" : "NO"));

    StringBuilder zones = new StringBuilder(100);
    L2WorldRegion region = L2World.getInstance().getRegion(activeChar.getX(), activeChar.getY());
    for (L2ZoneType zone : region.getZones()) {
      if (zone.isCharacterInZone(activeChar)) {
        StringUtil.append(zones, String.valueOf(zone.getId()));
        StringUtil.append(zones, " ");
      }
    }
    adminReply.replace("%ZLIST%", zones.toString());
    activeChar.sendPacket(adminReply);
  }
  /**
   * @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);
  }
 /**
  * @param activeChar
  * @param player
  */
 private void gatherCharacterInfo(L2PcInstance activeChar, L2PcInstance player, String filename) {
   String ip = "N/A";
   String account = "N/A";
   try {
     String clientInfo = player.getClient().toString();
     account =
         clientInfo.substring(clientInfo.indexOf("Account: ") + 9, clientInfo.indexOf(" - IP: "));
     ip = clientInfo.substring(clientInfo.indexOf(" - IP: ") + 7, clientInfo.lastIndexOf("]"));
   } catch (Exception e) {
   }
   NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
   adminReply.setFile("data/html/admin/" + filename);
   adminReply.replace("%name%", player.getName());
   adminReply.replace("%level%", String.valueOf(player.getLevel()));
   adminReply.replace(
       "%clan%", String.valueOf(ClanTable.getInstance().getClan(player.getClanId())));
   adminReply.replace("%xp%", String.valueOf(player.getExp()));
   adminReply.replace("%sp%", String.valueOf(player.getSp()));
   adminReply.replace("%class%", player.getTemplate().className);
   adminReply.replace("%ordinal%", String.valueOf(player.getClassId().ordinal()));
   adminReply.replace("%classid%", String.valueOf(player.getClassId()));
   adminReply.replace("%x%", String.valueOf(player.getX()));
   adminReply.replace("%y%", String.valueOf(player.getY()));
   adminReply.replace("%z%", String.valueOf(player.getZ()));
   adminReply.replace("%currenthp%", String.valueOf((int) player.getCurrentHp()));
   adminReply.replace("%maxhp%", String.valueOf(player.getMaxHp()));
   adminReply.replace("%karma%", String.valueOf(player.getKarma()));
   adminReply.replace("%currentmp%", String.valueOf((int) player.getCurrentMp()));
   adminReply.replace("%maxmp%", String.valueOf(player.getMaxMp()));
   adminReply.replace("%pvpflag%", String.valueOf(player.getPvpFlag()));
   adminReply.replace("%currentcp%", String.valueOf((int) player.getCurrentCp()));
   adminReply.replace("%maxcp%", String.valueOf(player.getMaxCp()));
   adminReply.replace("%pvpkills%", String.valueOf(player.getPvpKills()));
   adminReply.replace("%pkkills%", String.valueOf(player.getPkKills()));
   adminReply.replace("%currentload%", String.valueOf(player.getCurrentLoad()));
   adminReply.replace("%maxload%", String.valueOf(player.getMaxLoad()));
   adminReply.replace(
       "%percent%",
       String.valueOf(
           Util.roundTo(
               ((float) player.getCurrentLoad() / (float) player.getMaxLoad()) * 100, 2)));
   adminReply.replace("%patk%", String.valueOf(player.getPAtk(null)));
   adminReply.replace("%matk%", String.valueOf(player.getMAtk(null, null)));
   adminReply.replace("%pdef%", String.valueOf(player.getPDef(null)));
   adminReply.replace("%mdef%", String.valueOf(player.getMDef(null, null)));
   adminReply.replace("%accuracy%", String.valueOf(player.getAccuracy()));
   adminReply.replace("%evasion%", String.valueOf(player.getEvasionRate(null)));
   adminReply.replace("%critical%", String.valueOf(player.getCriticalHit(null, null)));
   adminReply.replace("%runspeed%", String.valueOf(player.getRunSpeed()));
   adminReply.replace("%patkspd%", String.valueOf(player.getPAtkSpd()));
   adminReply.replace("%matkspd%", String.valueOf(player.getMAtkSpd()));
   adminReply.replace("%access%", String.valueOf(player.getAccessLevel().getLevel()));
   adminReply.replace("%account%", account);
   adminReply.replace("%ip%", ip);
   activeChar.sendPacket(adminReply);
 }
Beispiel #14
0
 private static void showSiegePage(L2PcInstance activeChar, String castleName) {
   final NpcHtmlMessage html = new NpcHtmlMessage(0);
   html.setFile("data/html/admin/castle.htm");
   html.replace("%castleName%", castleName);
   activeChar.sendPacket(html);
 }
Beispiel #15
0
  private static void showCastleSelectPage(L2PcInstance activeChar) {
    int i = 0;

    final NpcHtmlMessage html = new NpcHtmlMessage(0);
    html.setFile("data/html/admin/castles.htm");

    final StringBuilder sb = new StringBuilder();
    for (Castle castle : CastleManager.getInstance().getCastles()) {
      if (castle != null) {
        StringUtil.append(
            sb,
            "<td fixwidth=90><a action=\"bypass -h admin_siege ",
            castle.getName(),
            "\">",
            castle.getName(),
            "</a></td>");
        i++;
      }

      if (i > 2) {
        sb.append("</tr><tr>");
        i = 0;
      }
    }
    html.replace("%castles%", sb.toString());

    // Cleanup sb.
    sb.setLength(0);
    i = 0;

    for (ClanHall clanhall : ClanHallManager.getInstance().getClanHalls().values()) {
      if (clanhall != null) {
        StringUtil.append(
            sb,
            "<td fixwidth=134><a action=\"bypass -h admin_clanhall ",
            clanhall.getId(),
            "\">",
            clanhall.getName(),
            "</a></td>");
        i++;
      }

      if (i > 1) {
        sb.append("</tr><tr>");
        i = 0;
      }
    }
    html.replace("%clanhalls%", sb.toString());

    // Cleanup sb.
    sb.setLength(0);
    i = 0;

    for (ClanHall clanhall : ClanHallManager.getInstance().getFreeClanHalls().values()) {
      if (clanhall != null) {
        StringUtil.append(
            sb,
            "<td fixwidth=134><a action=\"bypass -h admin_clanhall ",
            clanhall.getId(),
            "\">",
            clanhall.getName(),
            "</a></td>");
        i++;
      }

      if (i > 1) {
        sb.append("</tr><tr>");
        i = 0;
      }
    }
    html.replace("%freeclanhalls%", sb.toString());
    activeChar.sendPacket(html);
  }