SkillTreesData.java 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.datatables;
  20. import java.io.File;
  21. import java.util.ArrayList;
  22. import java.util.Arrays;
  23. import java.util.Collection;
  24. import java.util.HashMap;
  25. import java.util.List;
  26. import java.util.Map;
  27. import java.util.Map.Entry;
  28. import java.util.Set;
  29. import org.w3c.dom.NamedNodeMap;
  30. import org.w3c.dom.Node;
  31. import com.l2jserver.Config;
  32. import com.l2jserver.gameserver.engines.DocumentParser;
  33. import com.l2jserver.gameserver.model.L2Clan;
  34. import com.l2jserver.gameserver.model.L2SkillLearn;
  35. import com.l2jserver.gameserver.model.L2SkillLearn.SubClassData;
  36. import com.l2jserver.gameserver.model.StatsSet;
  37. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  38. import com.l2jserver.gameserver.model.base.AcquireSkillType;
  39. import com.l2jserver.gameserver.model.base.ClassId;
  40. import com.l2jserver.gameserver.model.base.Race;
  41. import com.l2jserver.gameserver.model.base.SocialClass;
  42. import com.l2jserver.gameserver.model.base.SubClass;
  43. import com.l2jserver.gameserver.model.holders.ItemHolder;
  44. import com.l2jserver.gameserver.model.holders.SkillHolder;
  45. import com.l2jserver.gameserver.model.skills.L2Skill;
  46. import gnu.trove.map.hash.TIntObjectHashMap;
  47. /**
  48. * This class loads and manage the characters and pledges skills trees.<br>
  49. * Here can be found the following skill trees:<br>
  50. * <ul>
  51. * <li>Class skill trees: player skill trees for each class.</li>
  52. * <li>Transfer skill trees: player skill trees for each healer class.</lI>
  53. * <li>Collect skill tree: player skill tree for Gracia related skills.</li>
  54. * <li>Fishing skill tree: player skill tree for fishing related skills.</li>
  55. * <li>Transform skill tree: player skill tree for transformation related skills.</li>
  56. * <li>Sub-Class skill tree: player skill tree for sub-class related skills.</li>
  57. * <li>Noble skill tree: player skill tree for noblesse related skills.</li>
  58. * <li>Hero skill tree: player skill tree for heroes related skills.</li>
  59. * <li>GM skill tree: player skill tree for Game Master related skills.</li>
  60. * <li>Common skill tree: custom skill tree for players, skills in this skill tree will be available for all players.</li>
  61. * <li>Pledge skill tree: clan skill tree for main clan.</li>
  62. * <li>Sub-Pledge skill tree: clan skill tree for sub-clans.</li>
  63. * </ul>
  64. * For easy customization of player class skill trees, the parent Id of each class is taken from the XML data, this means you can use a different class parent Id than in the normal game play, for example all 3rd class dagger users will have Treasure Hunter skills as 1st and 2nd class skills.<br>
  65. * For XML schema please refer to skillTrees.xsd in datapack in xsd folder and for parameters documentation refer to documentation.txt in skillTrees folder.<br>
  66. * @author Zoey76
  67. */
  68. public final class SkillTreesData extends DocumentParser
  69. {
  70. // ClassId, FastMap of Skill Hash Code, L2SkillLearn
  71. private static final Map<ClassId, Map<Integer, L2SkillLearn>> _classSkillTrees = new HashMap<>();
  72. private static final Map<ClassId, Map<Integer, L2SkillLearn>> _transferSkillTrees = new HashMap<>();
  73. // Skill Hash Code, L2SkillLearn
  74. private static final Map<Integer, L2SkillLearn> _collectSkillTree = new HashMap<>();
  75. private static final Map<Integer, L2SkillLearn> _fishingSkillTree = new HashMap<>();
  76. private static final Map<Integer, L2SkillLearn> _pledgeSkillTree = new HashMap<>();
  77. private static final Map<Integer, L2SkillLearn> _subClassSkillTree = new HashMap<>();
  78. private static final Map<Integer, L2SkillLearn> _subPledgeSkillTree = new HashMap<>();
  79. private static final Map<Integer, L2SkillLearn> _transformSkillTree = new HashMap<>();
  80. private static final Map<Integer, L2SkillLearn> _commonSkillTree = new HashMap<>();
  81. // Other skill trees
  82. private static final Map<Integer, L2SkillLearn> _nobleSkillTree = new HashMap<>();
  83. private static final Map<Integer, L2SkillLearn> _heroSkillTree = new HashMap<>();
  84. private static final Map<Integer, L2SkillLearn> _gameMasterSkillTree = new HashMap<>();
  85. private static final Map<Integer, L2SkillLearn> _gameMasterAuraSkillTree = new HashMap<>();
  86. // Checker, sorted arrays of hash codes
  87. private TIntObjectHashMap<int[]> _skillsByClassIdHashCodes; // Occupation skills
  88. private TIntObjectHashMap<int[]> _skillsByRaceHashCodes; // Race-specific Transformations
  89. private int[] _allSkillsHashCodes; // Fishing, Collection, Transformations, Common Skills.
  90. private boolean _loading = true;
  91. /**
  92. * Parent class IDs are read from XML and stored in this map, to allow easy customization.
  93. */
  94. private static final Map<ClassId, ClassId> _parentClassMap = new HashMap<>();
  95. /**
  96. * Instantiates a new skill trees data.
  97. */
  98. protected SkillTreesData()
  99. {
  100. load();
  101. }
  102. @Override
  103. public void load()
  104. {
  105. _loading = true;
  106. _classSkillTrees.clear();
  107. _collectSkillTree.clear();
  108. _fishingSkillTree.clear();
  109. _pledgeSkillTree.clear();
  110. _subClassSkillTree.clear();
  111. _subPledgeSkillTree.clear();
  112. _transferSkillTrees.clear();
  113. _transformSkillTree.clear();
  114. _nobleSkillTree.clear();
  115. _heroSkillTree.clear();
  116. _gameMasterSkillTree.clear();
  117. _gameMasterAuraSkillTree.clear();
  118. // Load files.
  119. parseDirectory(new File(Config.DATAPACK_ROOT, "data/skillTrees/"));
  120. // Generate check arrays.
  121. generateCheckArrays();
  122. _loading = false;
  123. // Logs a report with skill trees info.
  124. report();
  125. }
  126. /**
  127. * Parse a skill tree file and store it into the correct skill tree.
  128. */
  129. @Override
  130. protected void parseDocument()
  131. {
  132. NamedNodeMap attrs;
  133. Node attr;
  134. String type = null;
  135. int cId = -1;
  136. int parentClassId = -1;
  137. ClassId classId = null;
  138. for (Node n = getCurrentDocument().getFirstChild(); n != null; n = n.getNextSibling())
  139. {
  140. if ("list".equalsIgnoreCase(n.getNodeName()))
  141. {
  142. for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
  143. {
  144. if ("skillTree".equalsIgnoreCase(d.getNodeName()))
  145. {
  146. final Map<Integer, L2SkillLearn> classSkillTree = new HashMap<>();
  147. final Map<Integer, L2SkillLearn> trasferSkillTree = new HashMap<>();
  148. type = d.getAttributes().getNamedItem("type").getNodeValue();
  149. attr = d.getAttributes().getNamedItem("classId");
  150. if (attr != null)
  151. {
  152. cId = Integer.parseInt(attr.getNodeValue());
  153. classId = ClassId.values()[cId];
  154. }
  155. else
  156. {
  157. cId = -1;
  158. }
  159. attr = d.getAttributes().getNamedItem("parentClassId");
  160. if (attr != null)
  161. {
  162. parentClassId = Integer.parseInt(attr.getNodeValue());
  163. if ((cId > -1) && (cId != parentClassId) && (parentClassId > -1) && !_parentClassMap.containsKey(classId))
  164. {
  165. _parentClassMap.put(classId, ClassId.values()[parentClassId]);
  166. }
  167. }
  168. for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
  169. {
  170. if ("skill".equalsIgnoreCase(c.getNodeName()))
  171. {
  172. final StatsSet learnSkillSet = new StatsSet();
  173. attrs = c.getAttributes();
  174. for (int i = 0; i < attrs.getLength(); i++)
  175. {
  176. attr = attrs.item(i);
  177. learnSkillSet.set(attr.getNodeName(), attr.getNodeValue());
  178. }
  179. final L2SkillLearn skillLearn = new L2SkillLearn(learnSkillSet);
  180. for (Node b = c.getFirstChild(); b != null; b = b.getNextSibling())
  181. {
  182. attrs = b.getAttributes();
  183. switch (b.getNodeName())
  184. {
  185. case "item":
  186. skillLearn.addRequiredItem(new ItemHolder(parseInt(attrs, "id"), parseInt(attrs, "count")));
  187. break;
  188. case "preRequisiteSkill":
  189. skillLearn.addPreReqSkill(new SkillHolder(parseInt(attrs, "id"), parseInt(attrs, "lvl")));
  190. break;
  191. case "race":
  192. skillLearn.addRace(Race.valueOf(b.getTextContent()));
  193. break;
  194. case "residenceId":
  195. skillLearn.addResidenceId(Integer.valueOf(b.getTextContent()));
  196. break;
  197. case "socialClass":
  198. skillLearn.setSocialClass(Enum.valueOf(SocialClass.class, b.getTextContent()));
  199. break;
  200. case "subClassConditions":
  201. skillLearn.addSubclassConditions(parseInt(attrs, "slot"), parseInt(attrs, "lvl"));
  202. break;
  203. }
  204. }
  205. final int skillHashCode = SkillTable.getSkillHashCode(skillLearn.getSkillId(), skillLearn.getSkillLevel());
  206. switch (type)
  207. {
  208. case "classSkillTree":
  209. {
  210. if (cId != -1)
  211. {
  212. classSkillTree.put(skillHashCode, skillLearn);
  213. }
  214. else
  215. {
  216. _commonSkillTree.put(skillHashCode, skillLearn);
  217. }
  218. break;
  219. }
  220. case "transferSkillTree":
  221. {
  222. trasferSkillTree.put(skillHashCode, skillLearn);
  223. break;
  224. }
  225. case "collectSkillTree":
  226. {
  227. _collectSkillTree.put(skillHashCode, skillLearn);
  228. break;
  229. }
  230. case "fishingSkillTree":
  231. {
  232. _fishingSkillTree.put(skillHashCode, skillLearn);
  233. break;
  234. }
  235. case "pledgeSkillTree":
  236. {
  237. _pledgeSkillTree.put(skillHashCode, skillLearn);
  238. break;
  239. }
  240. case "subClassSkillTree":
  241. {
  242. _subClassSkillTree.put(skillHashCode, skillLearn);
  243. break;
  244. }
  245. case "subPledgeSkillTree":
  246. {
  247. _subPledgeSkillTree.put(skillHashCode, skillLearn);
  248. break;
  249. }
  250. case "transformSkillTree":
  251. {
  252. _transformSkillTree.put(skillHashCode, skillLearn);
  253. break;
  254. }
  255. case "nobleSkillTree":
  256. {
  257. _nobleSkillTree.put(skillHashCode, skillLearn);
  258. break;
  259. }
  260. case "heroSkillTree":
  261. {
  262. _heroSkillTree.put(skillHashCode, skillLearn);
  263. break;
  264. }
  265. case "gameMasterSkillTree":
  266. {
  267. _gameMasterSkillTree.put(skillHashCode, skillLearn);
  268. break;
  269. }
  270. case "gameMasterAuraSkillTree":
  271. {
  272. _gameMasterAuraSkillTree.put(skillHashCode, skillLearn);
  273. break;
  274. }
  275. default:
  276. {
  277. _log.warning(getClass().getSimpleName() + ": Unknown Skill Tree type: " + type + "!");
  278. }
  279. }
  280. }
  281. }
  282. if (type.equals("transferSkillTree"))
  283. {
  284. _transferSkillTrees.put(classId, trasferSkillTree);
  285. }
  286. else if (type.equals("classSkillTree") && (cId > -1))
  287. {
  288. if (!_classSkillTrees.containsKey(classId))
  289. {
  290. _classSkillTrees.put(classId, classSkillTree);
  291. }
  292. else
  293. {
  294. _classSkillTrees.get(classId).putAll(classSkillTree);
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. /**
  303. * Method to get the complete skill tree for a given class id.<br>
  304. * Include all skills common to all classes.<br>
  305. * Includes all parent skill trees.
  306. * @param classId the class skill tree ID.
  307. * @return the complete Class Skill Tree including skill trees from parent class for a given {@code classId}.
  308. */
  309. public Map<Integer, L2SkillLearn> getCompleteClassSkillTree(ClassId classId)
  310. {
  311. final Map<Integer, L2SkillLearn> skillTree = new HashMap<>();
  312. // Add all skills that belong to all classes.
  313. skillTree.putAll(_commonSkillTree);
  314. while ((classId != null) && (_classSkillTrees.get(classId) != null))
  315. {
  316. skillTree.putAll(_classSkillTrees.get(classId));
  317. classId = _parentClassMap.get(classId);
  318. }
  319. return skillTree;
  320. }
  321. /**
  322. * Gets the transfer skill tree.<br>
  323. * If new classes are implemented over 3rd class, we use a recursive call.
  324. * @param classId the transfer skill tree ID.
  325. * @return the complete Transfer Skill Tree for a given {@code classId}.
  326. */
  327. public Map<Integer, L2SkillLearn> getTransferSkillTree(ClassId classId)
  328. {
  329. if (classId.level() >= 3)
  330. {
  331. return getTransferSkillTree(classId.getParent());
  332. }
  333. return _transferSkillTrees.get(classId);
  334. }
  335. /**
  336. * Gets the common skill tree.
  337. * @return the complete Common Skill Tree.
  338. */
  339. public Map<Integer, L2SkillLearn> getCommonSkillTree()
  340. {
  341. return _commonSkillTree;
  342. }
  343. /**
  344. * Gets the collect skill tree.
  345. * @return the complete Collect Skill Tree.
  346. */
  347. public Map<Integer, L2SkillLearn> getCollectSkillTree()
  348. {
  349. return _collectSkillTree;
  350. }
  351. /**
  352. * Gets the fishing skill tree.
  353. * @return the complete Fishing Skill Tree.
  354. */
  355. public Map<Integer, L2SkillLearn> getFishingSkillTree()
  356. {
  357. return _fishingSkillTree;
  358. }
  359. /**
  360. * Gets the pledge skill tree.
  361. * @return the complete Pledge Skill Tree.
  362. */
  363. public Map<Integer, L2SkillLearn> getPledgeSkillTree()
  364. {
  365. return _pledgeSkillTree;
  366. }
  367. /**
  368. * Gets the sub class skill tree.
  369. * @return the complete Sub-Class Skill Tree.
  370. */
  371. public Map<Integer, L2SkillLearn> getSubClassSkillTree()
  372. {
  373. return _subClassSkillTree;
  374. }
  375. /**
  376. * Gets the sub pledge skill tree.
  377. * @return the complete Sub-Pledge Skill Tree.
  378. */
  379. public Map<Integer, L2SkillLearn> getSubPledgeSkillTree()
  380. {
  381. return _subPledgeSkillTree;
  382. }
  383. /**
  384. * Gets the transform skill tree.
  385. * @return the complete Transform Skill Tree.
  386. */
  387. public Map<Integer, L2SkillLearn> getTransformSkillTree()
  388. {
  389. return _transformSkillTree;
  390. }
  391. /**
  392. * Gets the noble skill tree.
  393. * @return the complete Noble Skill Tree.
  394. */
  395. public Map<Integer, L2Skill> getNobleSkillTree()
  396. {
  397. final Map<Integer, L2Skill> tree = new HashMap<>();
  398. final SkillTable st = SkillTable.getInstance();
  399. for (Entry<Integer, L2SkillLearn> e : _nobleSkillTree.entrySet())
  400. {
  401. tree.put(e.getKey(), st.getInfo(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
  402. }
  403. return tree;
  404. }
  405. /**
  406. * Gets the hero skill tree.
  407. * @return the complete Hero Skill Tree.
  408. */
  409. public Map<Integer, L2Skill> getHeroSkillTree()
  410. {
  411. final Map<Integer, L2Skill> tree = new HashMap<>();
  412. final SkillTable st = SkillTable.getInstance();
  413. for (Entry<Integer, L2SkillLearn> e : _heroSkillTree.entrySet())
  414. {
  415. tree.put(e.getKey(), st.getInfo(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
  416. }
  417. return tree;
  418. }
  419. /**
  420. * Gets the gM skill tree.
  421. * @return the complete Game Master Skill Tree.
  422. */
  423. public Map<Integer, L2Skill> getGMSkillTree()
  424. {
  425. final Map<Integer, L2Skill> tree = new HashMap<>();
  426. final SkillTable st = SkillTable.getInstance();
  427. for (Entry<Integer, L2SkillLearn> e : _gameMasterSkillTree.entrySet())
  428. {
  429. tree.put(e.getKey(), st.getInfo(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
  430. }
  431. return tree;
  432. }
  433. /**
  434. * Gets the gM aura skill tree.
  435. * @return the complete Game Master Aura Skill Tree.
  436. */
  437. public Map<Integer, L2Skill> getGMAuraSkillTree()
  438. {
  439. final Map<Integer, L2Skill> tree = new HashMap<>();
  440. final SkillTable st = SkillTable.getInstance();
  441. for (Entry<Integer, L2SkillLearn> e : _gameMasterAuraSkillTree.entrySet())
  442. {
  443. tree.put(e.getKey(), st.getInfo(e.getValue().getSkillId(), e.getValue().getSkillLevel()));
  444. }
  445. return tree;
  446. }
  447. /**
  448. * Gets the available skills.
  449. * @param player the learning skill player.
  450. * @param classId the learning skill class ID.
  451. * @param includeByFs if {@code true} skills from Forgotten Scroll will be included.
  452. * @param includeAutoGet if {@code true} Auto-Get skills will be included.
  453. * @return all available skills for a given {@code player}, {@code classId}, {@code includeByFs} and {@code includeAutoGet}.
  454. */
  455. public List<L2SkillLearn> getAvailableSkills(L2PcInstance player, ClassId classId, boolean includeByFs, boolean includeAutoGet)
  456. {
  457. final List<L2SkillLearn> result = new ArrayList<>();
  458. final Map<Integer, L2SkillLearn> skills = getCompleteClassSkillTree(classId);
  459. if (skills.isEmpty())
  460. {
  461. // The Skill Tree for this class is undefined.
  462. _log.warning(getClass().getSimpleName() + ": Skilltree for class " + classId + " is not defined!");
  463. return result;
  464. }
  465. for (L2SkillLearn skill : skills.values())
  466. {
  467. if (((includeAutoGet && skill.isAutoGet()) || skill.isLearnedByNpc() || (includeByFs && skill.isLearnedByFS())) && (player.getLevel() >= skill.getGetLevel()))
  468. {
  469. final L2Skill oldSkill = player.getSkills().get(skill.getSkillId());
  470. if (oldSkill != null)
  471. {
  472. if (oldSkill.getLevel() == (skill.getSkillLevel() - 1))
  473. {
  474. result.add(skill);
  475. }
  476. }
  477. else if (skill.getSkillLevel() == 1)
  478. {
  479. result.add(skill);
  480. }
  481. }
  482. }
  483. return result;
  484. }
  485. /**
  486. * Gets the available auto get skills.
  487. * @param player the player requesting the Auto-Get skills.
  488. * @return all the available Auto-Get skills for a given {@code player}.
  489. */
  490. public List<L2SkillLearn> getAvailableAutoGetSkills(L2PcInstance player)
  491. {
  492. final List<L2SkillLearn> result = new ArrayList<>();
  493. final Map<Integer, L2SkillLearn> skills = getCompleteClassSkillTree(player.getClassId());
  494. if (skills.isEmpty())
  495. {
  496. // The Skill Tree for this class is undefined, so we return an empty list.
  497. _log.warning(getClass().getSimpleName() + ": Skill Tree for this class Id(" + player.getClassId() + ") is not defined!");
  498. return result;
  499. }
  500. final Race race = player.getRace();
  501. for (L2SkillLearn skill : skills.values())
  502. {
  503. if (!skill.getRaces().isEmpty() && !skill.getRaces().contains(race))
  504. {
  505. continue;
  506. }
  507. if (skill.isAutoGet() && (player.getLevel() >= skill.getGetLevel()))
  508. {
  509. final L2Skill oldSkill = player.getSkills().get(skill.getSkillId());
  510. if (oldSkill != null)
  511. {
  512. if (oldSkill.getLevel() < skill.getSkillLevel())
  513. {
  514. result.add(skill);
  515. }
  516. }
  517. else
  518. {
  519. result.add(skill);
  520. }
  521. }
  522. }
  523. return result;
  524. }
  525. /**
  526. * Dwarvens will get additional dwarven only fishing skills.
  527. * @param player the player
  528. * @return all the available Fishing skills for a given {@code player}.
  529. */
  530. public List<L2SkillLearn> getAvailableFishingSkills(L2PcInstance player)
  531. {
  532. final List<L2SkillLearn> result = new ArrayList<>();
  533. final Race playerRace = player.getRace();
  534. for (L2SkillLearn skill : _fishingSkillTree.values())
  535. {
  536. // If skill is Race specific and the player's race isn't allowed, skip it.
  537. if (!skill.getRaces().isEmpty() && !skill.getRaces().contains(playerRace))
  538. {
  539. continue;
  540. }
  541. if (skill.isLearnedByNpc() && (player.getLevel() >= skill.getGetLevel()))
  542. {
  543. final L2Skill oldSkill = player.getSkills().get(skill.getSkillId());
  544. if (oldSkill != null)
  545. {
  546. if (oldSkill.getLevel() == (skill.getSkillLevel() - 1))
  547. {
  548. result.add(skill);
  549. }
  550. }
  551. else if (skill.getSkillLevel() == 1)
  552. {
  553. result.add(skill);
  554. }
  555. }
  556. }
  557. return result;
  558. }
  559. /**
  560. * Used in Gracia continent.
  561. * @param player the collecting skill learning player.
  562. * @return all the available Collecting skills for a given {@code player}.
  563. */
  564. public List<L2SkillLearn> getAvailableCollectSkills(L2PcInstance player)
  565. {
  566. final List<L2SkillLearn> result = new ArrayList<>();
  567. for (L2SkillLearn skill : _collectSkillTree.values())
  568. {
  569. final L2Skill oldSkill = player.getSkills().get(skill.getSkillId());
  570. if (oldSkill != null)
  571. {
  572. if (oldSkill.getLevel() == (skill.getSkillLevel() - 1))
  573. {
  574. result.add(skill);
  575. }
  576. }
  577. else if (skill.getSkillLevel() == 1)
  578. {
  579. result.add(skill);
  580. }
  581. }
  582. return result;
  583. }
  584. /**
  585. * Gets the available transfer skills.
  586. * @param player the transfer skill learning player.
  587. * @return all the available Transfer skills for a given {@code player}.
  588. */
  589. public List<L2SkillLearn> getAvailableTransferSkills(L2PcInstance player)
  590. {
  591. final List<L2SkillLearn> result = new ArrayList<>();
  592. ClassId classId = player.getClassId();
  593. // If new classes are implemented over 3rd class, a different way should be implemented.
  594. if (classId.level() == 3)
  595. {
  596. classId = classId.getParent();
  597. }
  598. if (!_transferSkillTrees.containsKey(classId))
  599. {
  600. return result;
  601. }
  602. for (L2SkillLearn skill : _transferSkillTrees.get(classId).values())
  603. {
  604. // If player doesn't know this transfer skill:
  605. if (player.getKnownSkill(skill.getSkillId()) == null)
  606. {
  607. result.add(skill);
  608. }
  609. }
  610. return result;
  611. }
  612. /**
  613. * Some transformations are not available for some races.
  614. * @param player the transformation skill learning player.
  615. * @return all the available Transformation skills for a given {@code player}.
  616. */
  617. public List<L2SkillLearn> getAvailableTransformSkills(L2PcInstance player)
  618. {
  619. final List<L2SkillLearn> result = new ArrayList<>();
  620. final Race race = player.getRace();
  621. for (L2SkillLearn skill : _transformSkillTree.values())
  622. {
  623. if ((player.getLevel() >= skill.getGetLevel()) && (skill.getRaces().isEmpty() || skill.getRaces().contains(race)))
  624. {
  625. final L2Skill oldSkill = player.getSkills().get(skill.getSkillId());
  626. if (oldSkill != null)
  627. {
  628. if (oldSkill.getLevel() == (skill.getSkillLevel() - 1))
  629. {
  630. result.add(skill);
  631. }
  632. }
  633. else if (skill.getSkillLevel() == 1)
  634. {
  635. result.add(skill);
  636. }
  637. }
  638. }
  639. return result;
  640. }
  641. /**
  642. * Gets the available pledge skills.
  643. * @param clan the pledge skill learning clan.
  644. * @return all the available Pledge skills for a given {@code clan}.
  645. */
  646. public List<L2SkillLearn> getAvailablePledgeSkills(L2Clan clan)
  647. {
  648. final List<L2SkillLearn> result = new ArrayList<>();
  649. for (L2SkillLearn skill : _pledgeSkillTree.values())
  650. {
  651. if (!skill.isResidencialSkill() && (clan.getLevel() >= skill.getGetLevel()))
  652. {
  653. final L2Skill oldSkill = clan.getSkills().get(skill.getSkillId());
  654. if (oldSkill != null)
  655. {
  656. if (oldSkill.getLevel() == (skill.getSkillLevel() - 1))
  657. {
  658. result.add(skill);
  659. }
  660. }
  661. else if (skill.getSkillLevel() == 1)
  662. {
  663. result.add(skill);
  664. }
  665. }
  666. }
  667. return result;
  668. }
  669. /**
  670. * Gets the available sub pledge skills.
  671. * @param clan the sub-pledge skill learning clan.
  672. * @return all the available Sub-Pledge skills for a given {@code clan}.
  673. */
  674. public List<L2SkillLearn> getAvailableSubPledgeSkills(L2Clan clan)
  675. {
  676. final List<L2SkillLearn> result = new ArrayList<>();
  677. for (L2SkillLearn skill : _subPledgeSkillTree.values())
  678. {
  679. if ((clan.getLevel() >= skill.getGetLevel()) && clan.isLearnableSubSkill(skill.getSkillId(), skill.getSkillLevel()))
  680. {
  681. result.add(skill);
  682. }
  683. }
  684. return result;
  685. }
  686. /**
  687. * Gets the available sub class skills.
  688. * @param player the sub-class skill learning player.
  689. * @return all the available Sub-Class skills for a given {@code player}.
  690. */
  691. public List<L2SkillLearn> getAvailableSubClassSkills(L2PcInstance player)
  692. {
  693. final List<L2SkillLearn> result = new ArrayList<>();
  694. for (L2SkillLearn skill : _subClassSkillTree.values())
  695. {
  696. if (player.getLevel() >= skill.getGetLevel())
  697. {
  698. List<SubClassData> subClassConds = null;
  699. for (SubClass subClass : player.getSubClasses().values())
  700. {
  701. subClassConds = skill.getSubClassConditions();
  702. if (!subClassConds.isEmpty() && (subClass.getClassIndex() <= subClassConds.size()) && (subClass.getClassIndex() == subClassConds.get(subClass.getClassIndex() - 1).getSlot()) && (subClassConds.get(subClass.getClassIndex() - 1).getLvl() <= subClass.getLevel()))
  703. {
  704. final L2Skill oldSkill = player.getSkills().get(skill.getSkillId());
  705. if (oldSkill != null)
  706. {
  707. if (oldSkill.getLevel() == (skill.getSkillLevel() - 1))
  708. {
  709. result.add(skill);
  710. }
  711. }
  712. else if (skill.getSkillLevel() == 1)
  713. {
  714. result.add(skill);
  715. }
  716. }
  717. }
  718. }
  719. }
  720. return result;
  721. }
  722. /**
  723. * Gets the available residential skills.
  724. * @param residenceId the id of the Castle, Fort, Territory.
  725. * @return all the available Residential skills for a given {@code residenceId}.
  726. */
  727. public List<L2SkillLearn> getAvailableResidentialSkills(int residenceId)
  728. {
  729. final List<L2SkillLearn> result = new ArrayList<>();
  730. for (L2SkillLearn skill : _pledgeSkillTree.values())
  731. {
  732. if (skill.isResidencialSkill() && skill.getResidenceIds().contains(residenceId))
  733. {
  734. result.add(skill);
  735. }
  736. }
  737. return result;
  738. }
  739. /**
  740. * Just a wrapper for all skill trees.
  741. * @param skillType the skill type.
  742. * @param id the skill Id.
  743. * @param lvl the skill level.
  744. * @param player the player learning the skill.
  745. * @return the skill learn for the specified parameters.
  746. */
  747. public L2SkillLearn getSkillLearn(AcquireSkillType skillType, int id, int lvl, L2PcInstance player)
  748. {
  749. L2SkillLearn sl = null;
  750. switch (skillType)
  751. {
  752. case Class:
  753. sl = getClassSkill(id, lvl, player.getLearningClass());
  754. break;
  755. case Transform:
  756. sl = getTransformSkill(id, lvl);
  757. break;
  758. case Fishing:
  759. sl = getFishingSkill(id, lvl);
  760. break;
  761. case Pledge:
  762. sl = getPledgeSkill(id, lvl);
  763. break;
  764. case SubPledge:
  765. sl = getSubPledgeSkill(id, lvl);
  766. break;
  767. case Transfer:
  768. sl = getTransferSkill(id, lvl, player.getClassId());
  769. break;
  770. case SubClass:
  771. sl = getSubClassSkill(id, lvl);
  772. break;
  773. case Collect:
  774. sl = getCollectSkill(id, lvl);
  775. break;
  776. }
  777. return sl;
  778. }
  779. /**
  780. * Gets the transform skill.
  781. * @param id the transformation skill ID.
  782. * @param lvl the transformation skill level.
  783. * @return the transform skill from the Transform Skill Tree for a given {@code id} and {@code lvl}.
  784. */
  785. public L2SkillLearn getTransformSkill(int id, int lvl)
  786. {
  787. return _transformSkillTree.get(SkillTable.getSkillHashCode(id, lvl));
  788. }
  789. /**
  790. * Gets the class skill.
  791. * @param id the class skill ID.
  792. * @param lvl the class skill level.
  793. * @param classId the class skill tree ID.
  794. * @return the class skill from the Class Skill Trees for a given {@code classId}, {@code id} and {@code lvl}.
  795. */
  796. public L2SkillLearn getClassSkill(int id, int lvl, ClassId classId)
  797. {
  798. return getCompleteClassSkillTree(classId).get(SkillTable.getSkillHashCode(id, lvl));
  799. }
  800. /**
  801. * Gets the fishing skill.
  802. * @param id the fishing skill ID.
  803. * @param lvl the fishing skill level.
  804. * @return Fishing skill from the Fishing Skill Tree for a given {@code id} and {@code lvl}.
  805. */
  806. public L2SkillLearn getFishingSkill(int id, int lvl)
  807. {
  808. return _fishingSkillTree.get(SkillTable.getSkillHashCode(id, lvl));
  809. }
  810. /**
  811. * Gets the pledge skill.
  812. * @param id the pledge skill ID.
  813. * @param lvl the pledge skill level.
  814. * @return the pledge skill from the Pledge Skill Tree for a given {@code id} and {@code lvl}.
  815. */
  816. public L2SkillLearn getPledgeSkill(int id, int lvl)
  817. {
  818. return _pledgeSkillTree.get(SkillTable.getSkillHashCode(id, lvl));
  819. }
  820. /**
  821. * Gets the sub pledge skill.
  822. * @param id the sub-pledge skill ID.
  823. * @param lvl the sub-pledge skill level.
  824. * @return the sub-pledge skill from the Sub-Pledge Skill Tree for a given {@code id} and {@code lvl}.
  825. */
  826. public L2SkillLearn getSubPledgeSkill(int id, int lvl)
  827. {
  828. return _subPledgeSkillTree.get(SkillTable.getSkillHashCode(id, lvl));
  829. }
  830. /**
  831. * Gets the transfer skill.
  832. * @param id the transfer skill ID.
  833. * @param lvl the transfer skill level.
  834. * @param classId the transfer skill tree ID.
  835. * @return the transfer skill from the Transfer Skill Trees for a given {@code classId}, {@code id} and {@code lvl}.
  836. */
  837. public L2SkillLearn getTransferSkill(int id, int lvl, ClassId classId)
  838. {
  839. if (classId.getParent() != null)
  840. {
  841. final ClassId parentId = classId.getParent();
  842. if (_transferSkillTrees.get(parentId) != null)
  843. {
  844. return _transferSkillTrees.get(parentId).get(SkillTable.getSkillHashCode(id, lvl));
  845. }
  846. }
  847. return null;
  848. }
  849. /**
  850. * Gets the sub class skill.
  851. * @param id the sub-class skill ID.
  852. * @param lvl the sub-class skill level.
  853. * @return the sub-class skill from the Sub-Class Skill Tree for a given {@code id} and {@code lvl}.
  854. */
  855. public L2SkillLearn getSubClassSkill(int id, int lvl)
  856. {
  857. return _subClassSkillTree.get(SkillTable.getSkillHashCode(id, lvl));
  858. }
  859. /**
  860. * Gets the common skill.
  861. * @param id the common skill Id.
  862. * @param lvl the common skill level.
  863. * @return the common skill from the Common Skill Tree for a given {@code id} and {@code lvl}.
  864. */
  865. public L2SkillLearn getCommonSkill(int id, int lvl)
  866. {
  867. return _commonSkillTree.get(SkillTable.getSkillHashCode(id, lvl));
  868. }
  869. /**
  870. * Gets the collect skill.
  871. * @param id the collect skill ID.
  872. * @param lvl the collect skill level.
  873. * @return the collect skill from the Collect Skill Tree for a given {@code id} and {@code lvl}.
  874. */
  875. public L2SkillLearn getCollectSkill(int id, int lvl)
  876. {
  877. return _collectSkillTree.get(SkillTable.getSkillHashCode(id, lvl));
  878. }
  879. /**
  880. * Gets the min level for new skill.
  881. * @param player the player that requires the minimum level.
  882. * @param skillTree the skill tree to search the minimum get level.
  883. * @return the minimum level for a new skill for a given {@code player} and {@code skillTree}.
  884. */
  885. public int getMinLevelForNewSkill(L2PcInstance player, Map<Integer, L2SkillLearn> skillTree)
  886. {
  887. int minLevel = 0;
  888. if (skillTree.isEmpty())
  889. {
  890. _log.warning(getClass().getSimpleName() + ": SkillTree is not defined for getMinLevelForNewSkill!");
  891. }
  892. else
  893. {
  894. for (L2SkillLearn s : skillTree.values())
  895. {
  896. if (s.isLearnedByNpc() && (player.getLevel() < s.getGetLevel()))
  897. {
  898. if ((minLevel == 0) || (minLevel > s.getGetLevel()))
  899. {
  900. minLevel = s.getGetLevel();
  901. }
  902. }
  903. }
  904. }
  905. return minLevel;
  906. }
  907. /**
  908. * Checks if is hero skill.
  909. * @param skillId the Id of the skill to check.
  910. * @param skillLevel the level of the skill to check, if it's -1 only Id will be checked.
  911. * @return {@code true} if the skill is present in the Hero Skill Tree, {@code false} otherwise.
  912. */
  913. public boolean isHeroSkill(int skillId, int skillLevel)
  914. {
  915. if (_heroSkillTree.containsKey(SkillTable.getSkillHashCode(skillId, skillLevel)))
  916. {
  917. return true;
  918. }
  919. for (L2SkillLearn skill : _heroSkillTree.values())
  920. {
  921. if ((skill.getSkillId() == skillId) && (skillLevel == -1))
  922. {
  923. return true;
  924. }
  925. }
  926. return false;
  927. }
  928. /**
  929. * Checks if is GM skill.
  930. * @param skillId skillId the Id of the skill to check.
  931. * @param skillLevel skillLevel the level of the skill to check, if it's -1 only Id will be checked.
  932. * @return {@code true} if the skill is present in the Game Master Skill Trees, {@code false} otherwise.
  933. */
  934. public boolean isGMSkill(int skillId, int skillLevel)
  935. {
  936. final Map<Integer, L2SkillLearn> gmSkills = new HashMap<>();
  937. gmSkills.putAll(_gameMasterSkillTree);
  938. gmSkills.putAll(_gameMasterAuraSkillTree);
  939. if (gmSkills.containsKey(SkillTable.getSkillHashCode(skillId, skillLevel)))
  940. {
  941. return true;
  942. }
  943. for (L2SkillLearn skill : gmSkills.values())
  944. {
  945. if ((skill.getSkillId() == skillId) && (skillLevel == -1))
  946. {
  947. return true;
  948. }
  949. }
  950. return false;
  951. }
  952. /**
  953. * Adds the skills.
  954. * @param gmchar the player to add the Game Master skills.
  955. * @param auraSkills if {@code true} it will add "GM Aura" skills, else will add the "GM regular" skills.
  956. */
  957. public void addSkills(L2PcInstance gmchar, boolean auraSkills)
  958. {
  959. final Collection<L2SkillLearn> skills = auraSkills ? _gameMasterAuraSkillTree.values() : _gameMasterSkillTree.values();
  960. final SkillTable st = SkillTable.getInstance();
  961. for (L2SkillLearn sl : skills)
  962. {
  963. gmchar.addSkill(st.getInfo(sl.getSkillId(), sl.getSkillLevel()), false); // Don't Save GM skills to database
  964. }
  965. }
  966. /**
  967. * Create and store hash values for skills for easy and fast checks.
  968. */
  969. private void generateCheckArrays()
  970. {
  971. int i;
  972. int[] array;
  973. // Class specific skills:
  974. Map<Integer, L2SkillLearn> tempMap;
  975. final Set<ClassId> keySet = _classSkillTrees.keySet();
  976. _skillsByClassIdHashCodes = new TIntObjectHashMap<>(keySet.size());
  977. for (ClassId cls : keySet)
  978. {
  979. i = 0;
  980. tempMap = getCompleteClassSkillTree(cls);
  981. array = new int[tempMap.size()];
  982. for (int h : tempMap.keySet())
  983. {
  984. array[i++] = h;
  985. }
  986. tempMap.clear();
  987. Arrays.sort(array);
  988. _skillsByClassIdHashCodes.put(cls.ordinal(), array);
  989. }
  990. // Race specific skills from Fishing and Transformation skill trees.
  991. final List<Integer> list = new ArrayList<>();
  992. _skillsByRaceHashCodes = new TIntObjectHashMap<>(Race.values().length);
  993. for (Race r : Race.values())
  994. {
  995. for (L2SkillLearn s : _fishingSkillTree.values())
  996. {
  997. if (s.getRaces().contains(r))
  998. {
  999. list.add(SkillTable.getSkillHashCode(s.getSkillId(), s.getSkillLevel()));
  1000. }
  1001. }
  1002. for (L2SkillLearn s : _transformSkillTree.values())
  1003. {
  1004. if (s.getRaces().contains(r))
  1005. {
  1006. list.add(SkillTable.getSkillHashCode(s.getSkillId(), s.getSkillLevel()));
  1007. }
  1008. }
  1009. i = 0;
  1010. array = new int[list.size()];
  1011. for (int s : list)
  1012. {
  1013. array[i++] = s;
  1014. }
  1015. Arrays.sort(array);
  1016. _skillsByRaceHashCodes.put(r.ordinal(), array);
  1017. list.clear();
  1018. }
  1019. // Skills available for all classes and races
  1020. for (L2SkillLearn s : _commonSkillTree.values())
  1021. {
  1022. if (s.getRaces().isEmpty())
  1023. {
  1024. list.add(SkillTable.getSkillHashCode(s.getSkillId(), s.getSkillLevel()));
  1025. }
  1026. }
  1027. for (L2SkillLearn s : _fishingSkillTree.values())
  1028. {
  1029. if (s.getRaces().isEmpty())
  1030. {
  1031. list.add(SkillTable.getSkillHashCode(s.getSkillId(), s.getSkillLevel()));
  1032. }
  1033. }
  1034. for (L2SkillLearn s : _transformSkillTree.values())
  1035. {
  1036. if (s.getRaces().isEmpty())
  1037. {
  1038. list.add(SkillTable.getSkillHashCode(s.getSkillId(), s.getSkillLevel()));
  1039. }
  1040. }
  1041. for (L2SkillLearn s : _collectSkillTree.values())
  1042. {
  1043. list.add(SkillTable.getSkillHashCode(s.getSkillId(), s.getSkillLevel()));
  1044. }
  1045. _allSkillsHashCodes = new int[list.size()];
  1046. int j = 0;
  1047. for (int hashcode : list)
  1048. {
  1049. _allSkillsHashCodes[j++] = hashcode;
  1050. }
  1051. Arrays.sort(_allSkillsHashCodes);
  1052. }
  1053. /**
  1054. * Verify if the give skill is valid for the given player.<br>
  1055. * GM's skills are excluded for GM players.
  1056. * @param player the player to verify the skill.
  1057. * @param skill the skill to be verified.
  1058. * @return {@code true} if the skill is allowed to the given player.
  1059. */
  1060. public boolean isSkillAllowed(L2PcInstance player, L2Skill skill)
  1061. {
  1062. if (skill.isExcludedFromCheck())
  1063. {
  1064. return true;
  1065. }
  1066. if (player.isGM() && skill.isGMSkill())
  1067. {
  1068. return true;
  1069. }
  1070. // Prevent accidental skill remove during reload
  1071. if (_loading)
  1072. {
  1073. return true;
  1074. }
  1075. final int maxLvl = SkillTable.getInstance().getMaxLevel(skill.getId());
  1076. final int hashCode = SkillTable.getSkillHashCode(skill.getId(), Math.min(skill.getLevel(), maxLvl));
  1077. if (Arrays.binarySearch(_skillsByClassIdHashCodes.get(player.getClassId().ordinal()), hashCode) >= 0)
  1078. {
  1079. return true;
  1080. }
  1081. if (Arrays.binarySearch(_skillsByRaceHashCodes.get(player.getRace().ordinal()), hashCode) >= 0)
  1082. {
  1083. return true;
  1084. }
  1085. if (Arrays.binarySearch(_allSkillsHashCodes, hashCode) >= 0)
  1086. {
  1087. return true;
  1088. }
  1089. // Exclude Transfer Skills from this check.
  1090. if (getTransferSkill(skill.getId(), Math.min(skill.getLevel(), maxLvl), player.getClassId()) != null)
  1091. {
  1092. return true;
  1093. }
  1094. return false;
  1095. }
  1096. /**
  1097. * Logs current Skill Trees skills count.
  1098. */
  1099. private void report()
  1100. {
  1101. int classSkillTreeCount = 0;
  1102. for (Map<Integer, L2SkillLearn> classSkillTree : _classSkillTrees.values())
  1103. {
  1104. classSkillTreeCount += classSkillTree.size();
  1105. }
  1106. int trasferSkillTreeCount = 0;
  1107. for (Map<Integer, L2SkillLearn> trasferSkillTree : _transferSkillTrees.values())
  1108. {
  1109. trasferSkillTreeCount += trasferSkillTree.size();
  1110. }
  1111. int dwarvenOnlyFishingSkillCount = 0;
  1112. for (L2SkillLearn fishSkill : _fishingSkillTree.values())
  1113. {
  1114. if (fishSkill.getRaces().contains(Race.Dwarf))
  1115. {
  1116. dwarvenOnlyFishingSkillCount++;
  1117. }
  1118. }
  1119. int resSkillCount = 0;
  1120. for (L2SkillLearn pledgeSkill : _pledgeSkillTree.values())
  1121. {
  1122. if (pledgeSkill.isResidencialSkill())
  1123. {
  1124. resSkillCount++;
  1125. }
  1126. }
  1127. final String className = getClass().getSimpleName();
  1128. _log.info(className + ": Loaded " + classSkillTreeCount + " Class Skills for " + _classSkillTrees.size() + " Class Skill Trees.");
  1129. _log.info(className + ": Loaded " + _subClassSkillTree.size() + " Sub-Class Skills.");
  1130. _log.info(className + ": Loaded " + trasferSkillTreeCount + " Transfer Skills for " + _transferSkillTrees.size() + " Transfer Skill Trees.");
  1131. _log.info(className + ": Loaded " + _fishingSkillTree.size() + " Fishing Skills, " + dwarvenOnlyFishingSkillCount + " Dwarven only Fishing Skills.");
  1132. _log.info(className + ": Loaded " + _collectSkillTree.size() + " Collect Skills.");
  1133. _log.info(className + ": Loaded " + _pledgeSkillTree.size() + " Pledge Skills, " + (_pledgeSkillTree.size() - resSkillCount) + " for Pledge and " + resSkillCount + " Residential.");
  1134. _log.info(className + ": Loaded " + _subPledgeSkillTree.size() + " Sub-Pledge Skills.");
  1135. _log.info(className + ": Loaded " + _transformSkillTree.size() + " Transform Skills.");
  1136. _log.info(className + ": Loaded " + _nobleSkillTree.size() + " Noble Skills.");
  1137. _log.info(className + ": Loaded " + _heroSkillTree.size() + " Hero Skills.");
  1138. _log.info(className + ": Loaded " + _gameMasterSkillTree.size() + " Game Master Skills.");
  1139. _log.info(className + ": Loaded " + _gameMasterAuraSkillTree.size() + " Game Master Aura Skills.");
  1140. final int commonSkills = _commonSkillTree.size();
  1141. if (commonSkills > 0)
  1142. {
  1143. _log.info(className + ": Loaded " + commonSkills + " Common Skills to all classes.");
  1144. }
  1145. }
  1146. /**
  1147. * Gets the single instance of SkillTreesData.
  1148. * @return the only instance of this class.
  1149. */
  1150. public static SkillTreesData getInstance()
  1151. {
  1152. return SingletonHolder._instance;
  1153. }
  1154. /**
  1155. * Singleton holder for the SkillTreesData class.
  1156. */
  1157. private static class SingletonHolder
  1158. {
  1159. protected static final SkillTreesData _instance = new SkillTreesData();
  1160. }
  1161. }