Document doc = factory.newDocumentBuilder().parse(file);
NamedNodeMap attrs;
byte type, roomId;
int mobId, x, y, z, delay, count;
L2Spawn spawnDat;
L2NpcTemplate template;
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 = Byte.parseByte(attrs.getNamedItem("type").getNodeValue());
for (Node room = area.getFirstChild(); room != null; room = room.getNextSibling())
{
if ("room".equalsIgnoreCase(room.getNodeName()))
{
attrs = room.getAttributes();
roomId = Byte.parseByte(attrs.getNamedItem("id").getNodeValue());
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 = NpcTable.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!");
for (int i = 0; i < count; i++)
{
DimensionalRiftRoom riftRoom = _rooms.get(type).get(roomId);
x = riftRoom.getRandomX();
y = riftRoom.getRandomY();
z = riftRoom.getTeleportCoords()[2];
if (template != null && _rooms.containsKey(type) && _rooms.get(type).containsKey(roomId))
{
spawnDat = new L2Spawn(template);
spawnDat.setAmount(1);
spawnDat.setLocx(x);
spawnDat.setLocy(y);
spawnDat.setLocz(z);
spawnDat.setHeading(-1);
spawnDat.setRespawnDelay(delay);
SpawnTable.getInstance().addNewSpawn(spawnDat, false);
_rooms.get(type).get(roomId).getSpawns().add(spawnDat);
countGood++;
}
else