PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list ORDER BY id");
ResultSet classlist = statement.executeQuery();
Map<Integer, L2SkillLearn> map;
int parentClassId;
L2SkillLearn skillLearn;
while (classlist.next())
{
map = new FastMap<Integer, L2SkillLearn>();
parentClassId = classlist.getInt("parent_id");
classId = classlist.getInt("id");
PreparedStatement statement2 = con.prepareStatement("SELECT class_id, skill_id, level, name, sp, min_level FROM skill_trees where class_id=? ORDER BY skill_id, level");
statement2.setInt(1, classId);
ResultSet skilltree = statement2.executeQuery();
if (parentClassId != -1)
{
Map<Integer, L2SkillLearn> parentMap = getSkillTrees().get(ClassId.values()[parentClassId]);
map.putAll(parentMap);
}
int prevSkillId = -1;
while (skilltree.next())
{
int id = skilltree.getInt("skill_id");
int lvl = skilltree.getInt("level");
String name = skilltree.getString("name");
int minLvl = skilltree.getInt("min_level");
int cost = skilltree.getInt("sp");
if (prevSkillId != id)
prevSkillId = id;
skillLearn = new L2SkillLearn(id, lvl, minLvl, name, cost, 0, 0);
map.put(SkillTable.getSkillHashCode(id,lvl), skillLearn);
}
getSkillTrees().put(ClassId.values()[classId], map);
skilltree.close();
statement2.close();
count += map.size();
_log.fine("SkillTreeTable: skill tree for class " + classId + " has " + map.size() + " skills");
}
classlist.close();
statement.close();
}
catch (Exception e)
{
_log.severe("Error while creating skill tree (Class ID " + classId + "):" + e);
}
_log.config("SkillTreeTable: Loaded " + count + " skills.");
//Skill tree for fishing skill (from Fisherman)
int count2 = 0;
int count3 = 0;
try
{
_fishingSkillTrees = new FastList<L2SkillLearn>();
_expandDwarfCraftSkillTrees = new FastList<L2SkillLearn>();
PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost, isfordwarf FROM fishing_skill_trees ORDER BY skill_id, level");
ResultSet skilltree2 = statement.executeQuery();
int prevSkillId = -1;
while (skilltree2.next())
{
int id = skilltree2.getInt("skill_id");
int lvl = skilltree2.getInt("level");
String name = skilltree2.getString("name");
int minLvl = skilltree2.getInt("min_level");
int cost = skilltree2.getInt("sp");
int costId = skilltree2.getInt("costid");
int costCount = skilltree2.getInt("cost");
int isDwarven = skilltree2.getInt("isfordwarf");
if (prevSkillId != id)
prevSkillId = id;
L2SkillLearn skill = new L2SkillLearn(id, lvl, minLvl, name, cost, costId, costCount);
if (isDwarven == 0)
_fishingSkillTrees.add(skill);
else
_expandDwarfCraftSkillTrees.add(skill);