Пример #1
0
  public int getAreaCastle(L2Character activeChar) {
    L2MapRegion region = getMapRegion(activeChar);

    if (region == null) return 0;

    return region.getCastle();
  }
Пример #2
0
  /**
   * Get town name by character position
   *
   * @param activeChar
   * @return
   */
  public String getClosestTownName(L2Character activeChar) {
    L2MapRegion region = getMapRegion(activeChar);

    if (region == null) return "Aden Castle Town";

    return region.getTown();
  }
Пример #3
0
  public final int getMapRegionLocId(int locX, int locY) {
    L2MapRegion region = getMapRegion(locX, locY);
    if (region != null) return region.getLocId();

    if (Config.DEBUG_PATH)
      _log.log(
          Level.WARNING,
          "MapRegionManager: Player outside map regions at X,Y=" + locX + "," + locY);
    return 0;
  }
Пример #4
0
  public L2MapRegion getRestartRegion(L2Character activeChar, String point) {
    try {
      L2PcInstance player = ((L2PcInstance) activeChar);
      L2MapRegion region = _regions.get(point);

      if (region.getBannedRace().containsKey(player.getRace()))
        getRestartRegion(player, region.getBannedRace().get(player.getRace()));
      return region;
    } catch (Exception e) {
      return _regions.get("talking_island_town");
    }
  }
Пример #5
0
  private static void load() {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(false);
    factory.setIgnoringComments(true);

    for (File file : Util.getDatapackFiles("mapregion", ".xml")) {
      try {
        Document doc = factory.newDocumentBuilder().parse(file);
        for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
          if ("list".equalsIgnoreCase(n.getNodeName())) {
            for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling()) {
              if ("region".equalsIgnoreCase(d.getNodeName())) {
                NamedNodeMap attrs = d.getAttributes();
                Node att;
                String name = "";
                String town = "";
                int locId = -1;
                int castle = -1;
                int bbs = -1;

                att = attrs.getNamedItem("name");
                if (att == null) {
                  _log.severe("Missing name for MapRegion, skipping");
                  continue;
                }
                name = att.getNodeValue();

                att = attrs.getNamedItem("town");
                if (att == null) {
                  _log.severe("Missing town for MapRegion name: " + name + ", skipping");
                  continue;
                }
                town = att.getNodeValue();

                att = attrs.getNamedItem("locId");
                if (att == null) {
                  _log.severe("Missing locId for MapRegion name: " + name + ", skipping");
                  continue;
                }
                locId = Integer.parseInt(att.getNodeValue());

                att = attrs.getNamedItem("castle");
                if (att == null) {
                  _log.severe("Missing castle for MapRegion name: " + name + ", skipping");
                  continue;
                }
                castle = Integer.parseInt(att.getNodeValue());

                att = attrs.getNamedItem("bbs");
                if (att == null) {
                  _log.severe("Missing bbs for MapRegion name: " + name + ", skipping");
                  continue;
                }
                bbs = Integer.parseInt(att.getNodeValue());

                L2MapRegion region = new L2MapRegion(name, town, locId, castle, bbs);
                for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling()) {
                  if ("respawnPoint".equalsIgnoreCase(c.getNodeName())) {
                    attrs = c.getAttributes();
                    int spawnX = Integer.parseInt(attrs.getNamedItem("X").getNodeValue());
                    int spawnY = Integer.parseInt(attrs.getNamedItem("Y").getNodeValue());
                    int spawnZ = Integer.parseInt(attrs.getNamedItem("Z").getNodeValue());

                    Node val = attrs.getNamedItem("isOther");
                    boolean other = val != null && Boolean.parseBoolean(val.getNodeValue());

                    val = attrs.getNamedItem("isChaotic");
                    boolean chaotic = val != null && Boolean.parseBoolean(val.getNodeValue());

                    val = attrs.getNamedItem("isBanish");
                    boolean banish = val != null && Boolean.parseBoolean(val.getNodeValue());

                    if (other) region.addOtherSpawn(spawnX, spawnY, spawnZ);
                    else if (chaotic) region.addChaoticSpawn(spawnX, spawnY, spawnZ);
                    else if (banish) region.addBanishSpawn(spawnX, spawnY, spawnZ);
                    else region.addSpawn(spawnX, spawnY, spawnZ);
                  } else if ("map".equalsIgnoreCase(c.getNodeName())) {
                    attrs = c.getAttributes();
                    int mapX = Integer.parseInt(attrs.getNamedItem("X").getNodeValue());
                    int mapY = Integer.parseInt(attrs.getNamedItem("Y").getNodeValue());

                    region.addMap(mapX, mapY);
                  } else if ("banned".equalsIgnoreCase(c.getNodeName())) {
                    attrs = c.getAttributes();
                    String race = attrs.getNamedItem("race").getNodeValue();
                    String point = attrs.getNamedItem("point").getNodeValue();

                    region.addBannedRace(race, point);
                  }
                }
                _regions.put(name, region);
              }
            }
          }
        }
      } catch (Exception e) {
        _log.severe("MapRegion file (" + file.getAbsolutePath() + ") doesnt exists.");
      }
    }
  }
Пример #6
0
 public final L2MapRegion getMapRegion(int locX, int locY) {
   for (L2MapRegion region : _regions.values()) {
     if (region.isZoneInRegion(getMapRegionX(locX), getMapRegionY(locY))) return region;
   }
   return null;
 }