Document doc = factory.newDocumentBuilder().parse(file);
NamedNodeMap attrs;
int type;
int roomId;
int mobId, delay, count;
SimpleSpawner spawnDat;
NpcTemplate template;
Location tele = new Location();
int xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0;
boolean isBossRoom;
for (Node rift = doc.getFirstChild(); rift != null; rift = rift.getNextSibling())
{
if ("rift".equalsIgnoreCase(rift.getNodeName()))
{
for (Node area = rift.getFirstChild(); area != null; area = area.getNextSibling())
{
if ("area".equalsIgnoreCase(area.getNodeName()))
{
attrs = area.getAttributes();
type = Integer.parseInt(attrs.getNamedItem("type").getNodeValue());
for (Node room = area.getFirstChild(); room != null; room = room.getNextSibling())
{
if ("room".equalsIgnoreCase(room.getNodeName()))
{
attrs = room.getAttributes();
roomId = Integer.parseInt(attrs.getNamedItem("id").getNodeValue());
Node boss = attrs.getNamedItem("isBossRoom");
isBossRoom = (boss != null) && Boolean.parseBoolean(boss.getNodeValue());
Territory territory = null;
for (Node coord = room.getFirstChild(); coord != null; coord = coord.getNextSibling())
{
if ("teleport".equalsIgnoreCase(coord.getNodeName()))
{
attrs = coord.getAttributes();
tele = Location.parseLoc(attrs.getNamedItem("loc").getNodeValue());
}
else if ("zone".equalsIgnoreCase(coord.getNodeName()))
{
attrs = coord.getAttributes();
xMin = Integer.parseInt(attrs.getNamedItem("xMin").getNodeValue());
xMax = Integer.parseInt(attrs.getNamedItem("xMax").getNodeValue());
yMin = Integer.parseInt(attrs.getNamedItem("yMin").getNodeValue());
yMax = Integer.parseInt(attrs.getNamedItem("yMax").getNodeValue());
zMin = Integer.parseInt(attrs.getNamedItem("zMin").getNodeValue());
zMax = Integer.parseInt(attrs.getNamedItem("zMax").getNodeValue());
territory = new Territory().add(new Rectangle(xMin, yMin, xMax, yMax).setZmin(zMin).setZmax(zMax));
}
}
if (territory == null)
{
_log.error("DimensionalRiftManager: invalid spawn data for room id " + roomId + "!");
}
if (!_rooms.containsKey(type))
{
_rooms.put(type, new ConcurrentHashMap<Integer, DelusionChamberRoom>());
}
_rooms.get(type).put(roomId, new DelusionChamberRoom(territory, tele, isBossRoom));
for (Node spawn = room.getFirstChild(); spawn != null; spawn = spawn.getNextSibling())
{
if ("spawn".equalsIgnoreCase(spawn.getNodeName()))
{
attrs = spawn.getAttributes();
mobId = Integer.parseInt(attrs.getNamedItem("mobId").getNodeValue());
delay = Integer.parseInt(attrs.getNamedItem("delay").getNodeValue());
count = Integer.parseInt(attrs.getNamedItem("count").getNodeValue());
template = NpcHolder.getInstance().getTemplate(mobId);
if (template == null)
{
_log.warn("Template " + mobId + " not found!");
}
if (!_rooms.containsKey(type))
{
_log.warn("Type " + type + " not found!");
}
else if (!_rooms.get(type).containsKey(roomId))
{
_log.warn("Room " + roomId + " in Type " + type + " not found!");
}
if ((template != null) && _rooms.containsKey(type) && _rooms.get(type).containsKey(roomId))
{
spawnDat = new SimpleSpawner(template);
spawnDat.setTerritory(territory);
spawnDat.setHeading(-1);
spawnDat.setRespawnDelay(delay);
spawnDat.setAmount(count);
_rooms.get(type).get(roomId).getSpawns().add(spawnDat);
countGood++;
}
else
{