statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM spawnlist ORDER BY id");
}
ResultSet rset = statement.executeQuery();
L2Spawn spawnDat;
L2NpcTemplate template1;
while(rset.next())
{
template1 = NpcTable.getInstance().getTemplate(rset.getInt("npc_templateid"));
if(template1 != null)
{
if(template1.type.equalsIgnoreCase("L2SiegeGuard"))
{
// Don't spawn
}
else if(template1.type.equalsIgnoreCase("L2RaidBoss"))
{
// Don't spawn raidboss
}
else if (template1.type.equalsIgnoreCase("L2GrandBoss"))
{
// Don't spawn grandboss
}
else if(!Config.ALLOW_CLASS_MASTERS && template1.type.equals("L2ClassMaster"))
{
// Dont' spawn class masters
}
else
{
spawnDat = new L2Spawn(template1);
spawnDat.setId(rset.getInt("id"));
spawnDat.setAmount(rset.getInt("count"));
spawnDat.setLocx(rset.getInt("locx"));
spawnDat.setLocy(rset.getInt("locy"));
spawnDat.setLocz(rset.getInt("locz"));
spawnDat.setHeading(rset.getInt("heading"));
spawnDat.setRespawnDelay(rset.getInt("respawn_delay"));
int loc_id = rset.getInt("loc_id");
spawnDat.setLocation(loc_id);
//template1 = null;
switch(rset.getInt("periodOfDay"))
{
case 0: // default
_npcSpawnCount += spawnDat.init();
break;
case 1: // Day
DayNightSpawnManager.getInstance().addDayCreature(spawnDat);
_npcSpawnCount++;
break;
case 2: // Night
DayNightSpawnManager.getInstance().addNightCreature(spawnDat);
_npcSpawnCount++;
break;
}
_spawntable.put(spawnDat.getId(), spawnDat);
if(spawnDat.getId() > _highestId)
{
_highestId = spawnDat.getId();
}
if (spawnDat.getTemplate().getNpcId() == Olympiad.OLY_MANAGER)
{
Olympiad.olymanagers.add(spawnDat);
}
spawnDat = null;
}
}
else
{
_log.warning("SpawnTable: Data missing in NPC table for ID: {}. "+ rset.getInt("npc_templateid"));
}
}
statement.close();
rset.close();
}
catch(Exception e)
{
_log.severe("SpawnTable: Spawn could not be initialized "+ e);
}
finally
{
CloseUtil.close(con);
}
_log.finest("SpawnTable: Loaded {} Npc Spawn Locations. "+ _spawntable.size());
_log.finest("SpawnTable: Spawning completed, total number of NPCs in the world: {} "+ _npcSpawnCount);
//-------------------------------Custom Spawnlist----------------------------//
if(Config.CUSTOM_SPAWNLIST_TABLE)
{
try
{
con = L2DatabaseFactory.getInstance().getConnection(false);
final PreparedStatement statement;
if(Config.DELETE_GMSPAWN_ON_CUSTOM)
{
statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist where id NOT in ( select id from custom_notspawned where isCustom = false ) ORDER BY id");
}
else
{
statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist ORDER BY id");
}
//PreparedStatement statement = con.prepareStatement("SELECT id, count, npc_templateid, locx, locy, locz, heading, respawn_delay, loc_id, periodOfDay FROM custom_spawnlist ORDER BY id");
final ResultSet rset = statement.executeQuery();
L2Spawn spawnDat;
L2NpcTemplate template1;
while(rset.next())
{
template1 = NpcTable.getInstance().getTemplate(rset.getInt("npc_templateid"));
if(template1 != null)
{
if(template1.type.equalsIgnoreCase("L2SiegeGuard"))
{
// Don't spawn
}
else if(template1.type.equalsIgnoreCase("L2RaidBoss"))
{
// Don't spawn raidboss
}
else if(!Config.ALLOW_CLASS_MASTERS && template1.type.equals("L2ClassMaster"))
{
// Dont' spawn class masters
}
else
{
spawnDat = new L2Spawn(template1);
spawnDat.setId(rset.getInt("id"));
spawnDat.setAmount(rset.getInt("count"));
spawnDat.setLocx(rset.getInt("locx"));
spawnDat.setLocy(rset.getInt("locy"));
spawnDat.setLocz(rset.getInt("locz"));
spawnDat.setHeading(rset.getInt("heading"));
spawnDat.setRespawnDelay(rset.getInt("respawn_delay"));
int loc_id = rset.getInt("loc_id");
spawnDat.setLocation(loc_id);
switch(rset.getInt("periodOfDay"))
{
case 0: // default
_customSpawnCount += spawnDat.init();
break;
case 1: // Day
DayNightSpawnManager.getInstance().addDayCreature(spawnDat);
_customSpawnCount++;
break;
case 2: // Night
DayNightSpawnManager.getInstance().addNightCreature(spawnDat);
_customSpawnCount++;
break;
}
_spawntable.put(spawnDat.getId(), spawnDat);
if(spawnDat.getId() > _highestId)
{
_highestId = spawnDat.getId();
}
}
}
else
{