iiieva 248 Опубликовано 3 марта, 2013 При компиляции выдаёт вот такую вот ошибку, непойму как её исправить [javac] Compiling 1204 source files to C:\Documents and Settings\Admin\Рабочий стол\Source\gameserver\build\classes [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6 [javac] C:\Documents and Settings\Admin\Рабочий стол\Source\gameserver\head-src\com\l2jfrozen\gameserver\datatables\sql\SkillTreeTable.java:344: error: 'try' without 'catch' or 'finally' [javac] try [javac] ^ [javac] 1 error [javac] 1 warning BUILD FAILED /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * http://www.gnu.org/copyleft/gpl.html */ package com.l2jfrozen.gameserver.datatables.sql; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.logging.Logger; import javolution.util.FastList; import javolution.util.FastMap; import com.l2jfrozen.gameserver.datatables.SkillTable; import com.l2jfrozen.gameserver.model.L2TraderSkillLearn; import com.l2jfrozen.gameserver.model.L2EnchantSkillLearn; import com.l2jfrozen.gameserver.model.L2PledgeSkillLearn; import com.l2jfrozen.gameserver.model.L2Skill; import com.l2jfrozen.gameserver.model.L2SkillLearn; import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; import com.l2jfrozen.gameserver.model.base.ClassId; import com.l2jfrozen.util.CloseUtil; import com.l2jfrozen.util.database.L2DatabaseFactory; /** * This class ... * * @version $Revision: 1.13.2.2.2.8 $ $Date: 2005/04/06 16:13:25 $ */ public class SkillTreeTable { private final static Logger _log = Logger.getLogger(SkillTreeTable.class.getName()); private static SkillTreeTable _instance; private Map> _skillTrees; private List _fishingSkillTrees; //all common skills (teached by Fisherman) private List _expandDwarfCraftSkillTrees; //list of special skill for dwarf (expand dwarf craft) learned by class teacher private List _pledgeSkillTrees; //pledge skill list private List _TraderSkillTrees; // Transform Skills (Test) private List _enchantSkillTrees; //enchant skill list public static SkillTreeTable getInstance() { if(_instance == null) { _instance = new SkillTreeTable(); } return _instance; } /** * Return the minimum level needed to have this Expertise. * * * @param grade The grade level searched * @return */ public int getExpertiseLevel(int grade) { if(grade <= 0) return 0; // since expertise comes at same level for all classes we use paladin for now Map learnMap = getSkillTrees().get(ClassId.paladin); int skillHashCode = SkillTable.getSkillHashCode(239, grade); if(learnMap.containsKey(skillHashCode)) return learnMap.get(skillHashCode).getMinLevel(); return 0; } /** * Each class receives new skill on certain levels, this methods allow the retrieval of the minimum character level * of given class required to learn a given skill * * @param skillId The iD of the skill * @param classId The classId of the character * @param skillLvl The SkillLvl * @return The min level */ public int getMinSkillLevel(int skillId, ClassId classId, int skillLvl) { Map map = getSkillTrees().get(classId); int skillHashCode = SkillTable.getSkillHashCode(skillId, skillLvl); if(map.containsKey(skillHashCode)) return map.get(skillHashCode).getMinLevel(); return 0; } public int getMinSkillLevel(int skillId, int skillLvl) { int skillHashCode = SkillTable.getSkillHashCode(skillId, skillLvl); // Look on all classes for this skill (takes the first one found) for(Map map : getSkillTrees().values()) { // checks if the current class has this skill if(map.containsKey(skillHashCode)) return map.get(skillHashCode).getMinLevel(); } return 0; } private SkillTreeTable() { int classId = 0; int count = 0; Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(false); final PreparedStatement statement = con.prepareStatement("SELECT * FROM class_list ORDER BY id"); final ResultSet classlist = statement.executeQuery(); Map map; int parentClassId; L2SkillLearn skillLearn; while(classlist.next()) { map = new FastMap(); parentClassId = classlist.getInt("parent_id"); classId = classlist.getInt("id"); final 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); final ResultSet skilltree = statement2.executeQuery(); if(parentClassId != -1) { Map 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.finest("SkillTreeTable: skill tree for class {} has {} skills "+ classId+" "+ map.size()); } classlist.close(); statement.close(); } catch(Exception e) { _log.severe("Error while creating skill tree (Class ID {}): "+ classId+" "+ e); } _log.finest("SkillTreeTable: Loaded {} skills."+" "+ count); //Skill tree for fishing skill (from Fisherman) int count2 = 0; int count3 = 0; try { _fishingSkillTrees = new FastList(); _expandDwarfCraftSkillTrees = new FastList(); if (con == null) { con = L2DatabaseFactory.getInstance().getConnection(false); } final PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost, isfordwarf FROM fishing_skill_trees ORDER BY skill_id, level"); final 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); } } skilltree2.close(); statement.close(); count2 = _fishingSkillTrees.size(); count3 = _expandDwarfCraftSkillTrees.size(); } catch(Exception e) { _log.severe("Error while creating fishing skill table"+" "+ e); } int count4 = 0; try { _enchantSkillTrees = new FastList(); if (con == null) { con = L2DatabaseFactory.getInstance().getConnection(false); } final PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, base_lvl, sp, min_skill_lvl, exp, success_rate76, success_rate77, success_rate78 FROM enchant_skill_trees ORDER BY skill_id, level"); final ResultSet skilltree3 = statement.executeQuery(); int prevSkillId = -1; while(skilltree3.next()) { int id = skilltree3.getInt("skill_id"); int lvl = skilltree3.getInt("level"); String name = skilltree3.getString("name"); int baseLvl = skilltree3.getInt("base_lvl"); int minSkillLvl = skilltree3.getInt("min_skill_lvl"); int sp = skilltree3.getInt("sp"); int exp = skilltree3.getInt("exp"); byte rate76 = skilltree3.getByte("success_rate76"); byte rate77 = skilltree3.getByte("success_rate77"); byte rate78 = skilltree3.getByte("success_rate78"); if(prevSkillId != id) { prevSkillId = id; } _enchantSkillTrees.add(new L2EnchantSkillLearn(id, lvl, minSkillLvl, baseLvl, name, sp, exp, rate76, rate77, rate78)); } skilltree3.close(); statement.close(); count4 = _enchantSkillTrees.size(); } catch(Exception e) { _log.severe("Error while creating enchant skill table"+" "+ e); } int count5 = 0; try { _pledgeSkillTrees = new FastList(); if (con == null) { con = L2DatabaseFactory.getInstance().getConnection(false); } final PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, clan_lvl, repCost, itemId FROM pledge_skill_trees ORDER BY skill_id, level"); final ResultSet skilltree4 = statement.executeQuery(); int prevSkillId = -1; while(skilltree4.next()) { int id = skilltree4.getInt("skill_id"); int lvl = skilltree4.getInt("level"); String name = skilltree4.getString("name"); int baseLvl = skilltree4.getInt("clan_lvl"); int sp = skilltree4.getInt("repCost"); int itemId = skilltree4.getInt("itemId"); if(prevSkillId != id) { prevSkillId = id; } _pledgeSkillTrees.add(new L2PledgeSkillLearn(id, lvl, baseLvl, name, sp, itemId)); } skilltree4.close(); statement.close(); count5 = _pledgeSkillTrees.size(); } catch(Exception e) { _log.severe("Error while creating fishing skill table"+" "+ e); } finally { CloseUtil.close(con); } int count6 = 0; try { _TraderSkillTrees = new FastList(); if (con == null) { con = L2DatabaseFactory.getInstance().getConnection(false); } final PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost FROM trader_skill_trees ORDER BY skill_id, level"); final ResultSet skilltree4 = statement.executeQuery(); int prevSkillId = -1; while (skilltree5.next()) { int id = skilltree5.getInt("skill_id"); int lvl = skilltree5.getInt("level"); String name = skilltree5.getString("name"); int minLvl = skilltree5.getInt("min_level"); int cost = skilltree5.getInt("sp"); int costId = skilltree5.getInt("costid"); int costCount = skilltree5.getInt("cost"); if (prevSkillId != id) prevSkillId = id; L2TraderSkillLearn skill = new L2TraderSkillLearn(id, lvl, minLvl, name, cost, costId, costCount); _TraderSkillTrees.add(skill); } skilltree5.close(); statement.close(); count6 = _TraderSkillTrees.size(); } _log.finest("FishingSkillTreeTable: Loaded {} general skills."+" "+ count2); _log.finest("FishingSkillTreeTable: Loaded {} dwarven skills."+" "+ count3); _log.finest("EnchantSkillTreeTable: Loaded {} enchant skills."+" "+ count4); _log.finest("PledgeSkillTreeTable: Loaded {} pledge skills"+" "+ count5); } private Map> getSkillTrees() { if(_skillTrees == null) { _skillTrees = new FastMap>(); } return _skillTrees; } public L2SkillLearn[] getAvailableSkills(L2PcInstance cha, ClassId classId) { List result = new FastList(); Collection skills = getSkillTrees().get(classId).values(); L2Skill[] oldSkills = cha.getAllSkills(); for(L2SkillLearn temp : skills) { if(temp.getMinLevel() <= cha.getLevel()) { boolean knownSkill = false; for(int j = 0; j < oldSkills.length && !knownSkill; j++) { if(oldSkills[j].getId() == temp.getId()) { knownSkill = true; if(oldSkills[j].getLevel() == temp.getLevel() - 1) { // this is the next level of a skill that we know result.add(temp); } } } if(!knownSkill && temp.getLevel() == 1) { // this is a new skill result.add(temp); } } } return result.toArray(new L2SkillLearn[result.size()]); } public L2SkillLearn[] getAvailableSkills(L2PcInstance cha) { List result = new FastList(); List skills = new FastList(); skills.addAll(_fishingSkillTrees); if(cha.hasDwarvenCraft() && _expandDwarfCraftSkillTrees != null) { skills.addAll(_expandDwarfCraftSkillTrees); } L2Skill[] oldSkills = cha.getAllSkills(); for(L2SkillLearn temp : skills) { if(temp.getMinLevel() <= cha.getLevel()) { boolean knownSkill = false; for(int j = 0; j < oldSkills.length && !knownSkill; j++) { if(oldSkills[j].getId() == temp.getId()) { knownSkill = true; if(oldSkills[j].getLevel() == temp.getLevel() - 1) { // this is the next level of a skill that we know result.add(temp); } } } if(!knownSkill && temp.getLevel() == 1) { // this is a new skill result.add(temp); } } } return result.toArray(new L2SkillLearn[result.size()]); } public L2EnchantSkillLearn[] getAvailableEnchantSkills(L2PcInstance cha) { List result = new FastList(); List skills = new FastList(); skills.addAll(_enchantSkillTrees); L2Skill[] oldSkills = cha.getAllSkills(); for(L2EnchantSkillLearn temp : skills) { if(76 <= cha.getLevel()) { boolean knownSkill = false; for(int j = 0; j < oldSkills.length && !knownSkill; j++) { if(oldSkills[j].getId() == temp.getId()) { knownSkill = true; if(oldSkills[j].getLevel() == temp.getMinSkillLevel()) { // this is the next level of a skill that we know result.add(temp); } } } } } //cha.sendMessage("loaded "+ result.size()+" enchant skills for this char(You)"); return result.toArray(new L2EnchantSkillLearn[result.size()]); } public L2PledgeSkillLearn[] getAvailablePledgeSkills(L2PcInstance cha) { List result = new FastList(); List skills = _pledgeSkillTrees; if(skills == null) { // the skilltree for this class is undefined, so we give an empty list _log.warning("No clan skills defined!"); return new L2PledgeSkillLearn[0]; } L2Skill[] oldSkills = cha.getClan().getAllSkills(); for(L2PledgeSkillLearn temp : skills) { if(temp.getBaseLevel() <= cha.getClan().getLevel()) { boolean knownSkill = false; for(int j = 0; j < oldSkills.length && !knownSkill; j++) { if(oldSkills[j].getId() == temp.getId()) { knownSkill = true; if(oldSkills[j].getLevel() == temp.getLevel() - 1) { // this is the next level of a skill that we know result.add(temp); } } } if(!knownSkill && temp.getLevel() == 1) { // this is a new skill result.add(temp); } } } return result.toArray(new L2PledgeSkillLearn[result.size()]); } public L2TraderSkillLearn[] getAvailableTraderSkills(L2PcInstance cha) { List result = new FastList(); List skills = new FastList(); skills.addAll(_TraderSkillTrees); if (skills == null) { // the skilltree for this class is undefined, so we give an empty list _log.warning("Skilltree for fishing is not defined !"); return new L2TraderSkillLearn[0]; } L2Skill[] oldSkills = cha.getAllSkills(); for (L2TraderSkillLearn temp : skills) { if (temp.getMinLevel() <= cha.getLevel()) { boolean knownSkill = false; for (int j = 0; j < oldSkills.length && !knownSkill; j++) { if (oldSkills[j].getId() == temp.getId()) { knownSkill = true; if (oldSkills[j].getLevel() == temp.getLevel() - 1) { // this is the next level of a skill that we know result.add(temp); } } } if (!knownSkill && temp.getLevel() == 1) { // this is a new skill result.add(temp); } } } return result.toArray(new L2TraderSkillLearn[result.size()]); } /** * Returns all allowed skills for a given class. * * @param classId * @return all allowed skills for a given class. */ public Collection getAllowedSkills(ClassId classId) { return getSkillTrees().get(classId).values(); } public int getMinLevelForNewSkill(L2PcInstance cha, ClassId classId) { int minLevel = 0; Collection skills = getSkillTrees().get(classId).values(); if(skills == null) { // the skilltree for this class is undefined, so we give an empty list _log.warning("Skilltree for class {} is not defined !"+" "+ classId); return minLevel; } for(L2SkillLearn temp : skills) { if(temp.getMinLevel() > cha.getLevel() && temp.getSpCost() != 0) if(minLevel == 0 || temp.getMinLevel() < minLevel) { minLevel = temp.getMinLevel(); } } return minLevel; } public int getMinLevelForNewSkill(L2PcInstance cha) { int minLevel = 0; List skills = new FastList(); skills.addAll(_fishingSkillTrees); if(cha.hasDwarvenCraft() && _expandDwarfCraftSkillTrees != null) { skills.addAll(_expandDwarfCraftSkillTrees); } for(L2SkillLearn s : skills) { if(s.getMinLevel() > cha.getLevel()) if(minLevel == 0 || s.getMinLevel() < minLevel) { minLevel = s.getMinLevel(); } } return minLevel; } public int getMinLevelForNewTraderSkill(L2PcInstance cha) { int minLevel = 0; List skills = new FastList(); skills.addAll(_TraderSkillTrees); if (skills == null) { // the skilltree for this class is undefined, so we give an empty list _log.warning("SkillTree for Trader Skills is not defined !"); return minLevel; } for (L2TraderSkillLearn s : skills) { if (s.getMinLevel() > cha.getLevel()) if (minLevel == 0 || s.getMinLevel() < minLevel) minLevel = s.getMinLevel(); } return minLevel; } public int getSkillCost(L2PcInstance player, L2Skill skill) { int skillCost = 100000000; ClassId classId = player.getSkillLearningClassId(); int skillHashCode = SkillTable.getSkillHashCode(skill); if(getSkillTrees().get(classId).containsKey(skillHashCode)) { L2SkillLearn skillLearn = getSkillTrees().get(classId).get(skillHashCode); if(skillLearn.getMinLevel() <= player.getLevel()) { skillCost = skillLearn.getSpCost(); if(!player.getClassId().equalsOrChildOf(classId)) { if(skill.getCrossLearnAdd() < 0) return skillCost; skillCost += skill.getCrossLearnAdd(); skillCost *= skill.getCrossLearnMul(); } if(classId.getRace() != player.getRace() && !player.isSubClassActive()) { skillCost *= skill.getCrossLearnRace(); } if(classId.isMage() != player.getClassId().isMage()) { skillCost *= skill.getCrossLearnProf(); } } } return skillCost; } public int getSkillSpCost(L2PcInstance player, L2Skill skill) { int skillCost = 100000000; L2EnchantSkillLearn[] enchantSkillLearnList = getAvailableEnchantSkills(player); for(L2EnchantSkillLearn enchantSkillLearn : enchantSkillLearnList) { if(enchantSkillLearn.getId() != skill.getId()) { continue; } if(enchantSkillLearn.getLevel() != skill.getLevel()) { continue; } if(76 > player.getLevel()) { continue; } skillCost = enchantSkillLearn.getSpCost(); } return skillCost; } public int getSkillExpCost(L2PcInstance player, L2Skill skill) { int skillCost = 100000000; L2EnchantSkillLearn[] enchantSkillLearnList = getAvailableEnchantSkills(player); for(L2EnchantSkillLearn enchantSkillLearn : enchantSkillLearnList) { if(enchantSkillLearn.getId() != skill.getId()) { continue; } if(enchantSkillLearn.getLevel() != skill.getLevel()) { continue; } if(76 > player.getLevel()) { continue; } skillCost = enchantSkillLearn.getExp(); } return skillCost; } public byte getSkillRate(L2PcInstance player, L2Skill skill) { L2EnchantSkillLearn[] enchantSkillLearnList = getAvailableEnchantSkills(player); for(L2EnchantSkillLearn enchantSkillLearn : enchantSkillLearnList) { if(enchantSkillLearn.getId() != skill.getId()) { continue; } if(enchantSkillLearn.getLevel() != skill.getLevel()) { continue; } return enchantSkillLearn.getRate(player); } return 0; } } Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
ArtiSoft 65 Опубликовано 3 марта, 2013 (изменено) int count6 = 0; try { _TraderSkillTrees = new FastList(); if (con == null) { con = L2DatabaseFactory.getInstance().getConnection(false); } final PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost FROM trader_skill_trees ORDER BY skill_id, level"); final ResultSet skilltree4 = statement.executeQuery(); int prevSkillId = -1; while (skilltree5.next()) { int id = skilltree5.getInt("skill_id"); int lvl = skilltree5.getInt("level"); String name = skilltree5.getString("name"); int minLvl = skilltree5.getInt("min_level"); int cost = skilltree5.getInt("sp"); int costId = skilltree5.getInt("costid"); int costCount = skilltree5.getInt("cost"); if (prevSkillId != id) prevSkillId = id; L2TraderSkillLearn skill = new L2TraderSkillLearn(id, lvl, minLvl, name, cost, costId, costCount); _TraderSkillTrees.add(skill); } skilltree5.close(); statement.close(); count6 = _TraderSkillTrees.size(); } catch(Exception e) { _log.severe("Error while creating skill table); } finally { CloseUtil.close(con); } _log.finest("FishingSkillTreeTable: Loaded {} general skills."+" "+ count2); _log.finest("FishingSkillTreeTable: Loaded {} dwarven skills."+" "+ count3); _log.finest("EnchantSkillTreeTable: Loaded {} enchant skills."+" "+ count4); _log.finest("PledgeSkillTreeTable: Loaded {} pledge skills"+" "+ count5); } Изменено 3 марта, 2013 пользователем ArtiSoft 1 Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты
iiieva 248 Опубликовано 3 марта, 2013 int count6 = 0; try { _TraderSkillTrees = new FastList(); if (con == null) { con = L2DatabaseFactory.getInstance().getConnection(false); } final PreparedStatement statement = con.prepareStatement("SELECT skill_id, level, name, sp, min_level, costid, cost FROM trader_skill_trees ORDER BY skill_id, level"); final ResultSet skilltree4 = statement.executeQuery(); int prevSkillId = -1; while (skilltree5.next()) { int id = skilltree5.getInt("skill_id"); int lvl = skilltree5.getInt("level"); String name = skilltree5.getString("name"); int minLvl = skilltree5.getInt("min_level"); int cost = skilltree5.getInt("sp"); int costId = skilltree5.getInt("costid"); int costCount = skilltree5.getInt("cost"); if (prevSkillId != id) prevSkillId = id; L2TraderSkillLearn skill = new L2TraderSkillLearn(id, lvl, minLvl, name, cost, costId, costCount); _TraderSkillTrees.add(skill); } skilltree5.close(); statement.close(); count6 = _TraderSkillTrees.size(); } catch(Exception e) { _log.severe("Error while creating skill table); } finally { CloseUtil.close(con); } _log.finest("FishingSkillTreeTable: Loaded {} general skills."+" "+ count2); _log.finest("FishingSkillTreeTable: Loaded {} dwarven skills."+" "+ count3); _log.finest("EnchantSkillTreeTable: Loaded {} enchant skills."+" "+ count4); _log.finest("PledgeSkillTreeTable: Loaded {} pledge skills"+" "+ count5); } Спасибо помогло Поделиться сообщением Ссылка на сообщение Поделиться на другие сайты