Example #1
0
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    if (activeChar == null) return false;

    StringTokenizer st = new StringTokenizer(command, " ");
    String actualCommand = st.nextToken(); // Get actual command

    if (actualCommand.equalsIgnoreCase("admin_zone_check")) showHtml(activeChar);
    else if (actualCommand.equalsIgnoreCase("admin_zone_visual")) {
      String next = st.nextToken();
      if (next.equalsIgnoreCase("all")) {
        for (L2ZoneType zone : ZoneManager.getInstance().getZones(activeChar))
          zone.visualizeZone(activeChar.getZ());

        showHtml(activeChar);
      } else {
        int zoneId = Integer.parseInt(next);
        ZoneManager.getInstance().getZoneById(zoneId).visualizeZone(activeChar.getZ());
      }
    } else if (actualCommand.equalsIgnoreCase("admin_zone_visual_clear")) {
      ZoneManager.getInstance().clearDebugItems();
      showHtml(activeChar);
    }

    return true;
  }
Example #2
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);
  }