{
con = L2DatabaseFactory.getInstance().getConnection(false);
}
statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
final ResultSet npcskills = statement.executeQuery();
L2NpcTemplate npcDat = null;
L2Skill npcSkill = null;
while(npcskills.next())
{
int mobId = npcskills.getInt("npcid");
npcDat = _npcs.get(mobId);
if(npcDat == null)
{
continue;
}
int skillId = npcskills.getInt("skillid");
int level = npcskills.getInt("level");
if(npcDat.race == null && skillId == 4416)
{
npcDat.setRace(level);
continue;
}
npcSkill = SkillTable.getInstance().getInfo(skillId, level);
if(npcSkill == null)
{
continue;
}
npcDat.addSkill(npcSkill);
}
npcskills.close();
statement.close();
}
catch(Exception e)
{
_log.severe("NPCTable: Error reading NPC skills table"+" "+ e);
}
if(Config.CUSTOM_DROPLIST_TABLE)
try
{
if (con == null)
{
con = L2DatabaseFactory.getInstance().getConnection(false);
}
statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
{
"mobId", "itemId", "min", "max", "category", "chance"
}) + " FROM custom_droplist ORDER BY mobId, chance DESC");
ResultSet dropData = statement.executeQuery();
int cCount = 0;
while(dropData.next())
{
int mobId = dropData.getInt("mobId");
L2NpcTemplate npcDat = _npcs.get(mobId);
if(npcDat == null)
{
_log.warning("NPCTable: CUSTOM DROPLIST No npc correlating with id: {}"+" "+ mobId);
continue;
}
L2DropData dropDat = new L2DropData();
dropDat.setItemId(dropData.getInt("itemId"));
dropDat.setMinDrop(dropData.getInt("min"));
dropDat.setMaxDrop(dropData.getInt("max"));
dropDat.setChance(dropData.getInt("chance"));
int category = dropData.getInt("category");
npcDat.addDropData(dropDat, category);
cCount++;
//dropDat = null;
}
dropData.close();
statement.close();
_log.finest("CustomDropList : Added {} custom droplist"+" "+ cCount);
if(Config.ENABLE_CACHE_INFO)
{
FillDropList();
}
}
catch(Exception e)
{
_log.severe("NPCTable: Error reading NPC CUSTOM drop data"+" "+ e);
}
try
{
if (con == null)
{
con = L2DatabaseFactory.getInstance().getConnection(false);
}
statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
{
"mobId", "itemId", "min", "max", "category", "chance"
}) + " FROM droplist ORDER BY mobId, chance DESC");
ResultSet dropData = statement.executeQuery();
L2DropData dropDat = null;
L2NpcTemplate npcDat = null;
while(dropData.next())
{
int mobId = dropData.getInt("mobId");
npcDat = _npcs.get(mobId);
if(npcDat == null)
{
_log.warning("NPCTable: No npc correlating with id: {}"+" "+ mobId);
continue;
}
dropDat = new L2DropData();
dropDat.setItemId(dropData.getInt("itemId"));
dropDat.setMinDrop(dropData.getInt("min"));
dropDat.setMaxDrop(dropData.getInt("max"));
dropDat.setChance(dropData.getInt("chance"));
int category = dropData.getInt("category");
npcDat.addDropData(dropDat, category);
//dropDat = null;
}
dropData.close();
statement.close();
}
catch(Exception e)
{
_log.severe("NPCTable: Error reading NPC drop data"+" "+ e);
}
try
{
if (con == null)
{
con = L2DatabaseFactory.getInstance().getConnection(false);
}
statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
{
"npc_id", "class_id"
}
) + " FROM skill_learn");
final ResultSet learndata = statement.executeQuery();
while(learndata.next())
{
int npcId = learndata.getInt ("npc_id");
int classId = learndata.getInt("class_id");
L2NpcTemplate npc = getTemplate(npcId);
if (npc == null)
{
_log.warning("NPCTable: Error getting NPC template ID {} while trying to load skill trainer data."+" "+ npcId);
continue;
}
if(classId >= ClassId.values().length){
_log.warning("NPCTable: Error defining learning data for NPC "+npcId+": specified classId "+classId+" is higher then max one "+(ClassId.values().length-1)+" specified into ClassID Enum --> check your Database to be complient with it"+" "+ classId);
continue;
}
npc.addTeachInfo(ClassId.values()[classId]);
}
learndata.close();
statement.close();
}
catch(Exception e)
{
_log.severe("NPCTable: Error reading NPC trainer data"+" "+ e);
}
try
{
if (con == null)
{
con = L2DatabaseFactory.getInstance().getConnection(false);
}
statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
{
"boss_id", "minion_id", "amount_min", "amount_max"
}) + " FROM minions");
ResultSet minionData = statement.executeQuery();
L2MinionData minionDat = null;
L2NpcTemplate npcDat = null;
int cnt = 0;
while(minionData.next())
{
int raidId = minionData.getInt("boss_id");
npcDat = _npcs.get(raidId);
minionDat = new L2MinionData();
minionDat.setMinionId(minionData.getInt("minion_id"));
minionDat.setAmountMin(minionData.getInt("amount_min"));
minionDat.setAmountMax(minionData.getInt("amount_max"));
npcDat.addRaidData(minionDat);
cnt++;
}
minionData.close();
statement.close();