2
0

NpcTable.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.datatables;
  16. import java.sql.Connection;
  17. import java.sql.PreparedStatement;
  18. import java.sql.ResultSet;
  19. import java.sql.SQLException;
  20. import java.util.List;
  21. import java.util.Map;
  22. import java.util.Set;
  23. import java.util.logging.Level;
  24. import java.util.logging.Logger;
  25. import javolution.util.FastList;
  26. import javolution.util.FastMap;
  27. import net.sf.l2j.Config;
  28. import net.sf.l2j.L2DatabaseFactory;
  29. import net.sf.l2j.gameserver.model.L2DropCategory;
  30. import net.sf.l2j.gameserver.model.L2DropData;
  31. import net.sf.l2j.gameserver.model.L2MinionData;
  32. import net.sf.l2j.gameserver.model.L2Skill;
  33. import net.sf.l2j.gameserver.model.base.ClassId;
  34. import net.sf.l2j.gameserver.skills.Stats;
  35. import net.sf.l2j.gameserver.templates.StatsSet;
  36. import net.sf.l2j.gameserver.templates.chars.L2NpcTemplate;
  37. /**
  38. * This class ...
  39. *
  40. * @version $Revision: 1.8.2.6.2.9 $ $Date: 2005/04/06 16:13:25 $
  41. */
  42. public class NpcTable
  43. {
  44. private static Logger _log = Logger.getLogger(NpcTable.class.getName());
  45. private Map<Integer, L2NpcTemplate> _npcs;
  46. private boolean _initialized = false;
  47. public static NpcTable getInstance()
  48. {
  49. return SingletonHolder._instance;
  50. }
  51. private NpcTable()
  52. {
  53. _npcs = new FastMap<Integer, L2NpcTemplate>();
  54. restoreNpcData();
  55. }
  56. private void restoreNpcData()
  57. {
  58. Connection con = null;
  59. try
  60. {
  61. try
  62. {
  63. con = L2DatabaseFactory.getInstance().getConnection();
  64. PreparedStatement statement;
  65. statement = con.prepareStatement("SELECT "
  66. + L2DatabaseFactory.getInstance().safetyString(new String[] { "id", "idTemplate", "name", "serverSideName",
  67. "title", "serverSideTitle", "class", "collision_radius", "collision_height", "level", "sex", "type",
  68. "attackrange", "hp", "mp", "hpreg", "mpreg", "str", "con", "dex", "int", "wit", "men", "exp", "sp", "patk",
  69. "pdef", "matk", "mdef", "atkspd", "aggro", "matkspd", "rhand", "lhand", "armor", "walkspd", "runspd",
  70. "faction_id", "faction_range", "isUndead", "absorb_level", "absorb_type", "ss", "bss", "ss_rate", "AI",
  71. "drop_herbs" }) + " FROM npc");
  72. ResultSet npcdata = statement.executeQuery();
  73. fillNpcTable(npcdata, false);
  74. npcdata.close();
  75. statement.close();
  76. }
  77. catch (Exception e)
  78. {
  79. _log.log(Level.SEVERE, "NPCTable: Error creating NPC table.", e);
  80. }
  81. if (Config.CUSTOM_NPC_TABLE) // reload certain NPCs
  82. {
  83. try
  84. {
  85. con = L2DatabaseFactory.getInstance().getConnection();
  86. PreparedStatement statement;
  87. statement = con.prepareStatement("SELECT "
  88. + L2DatabaseFactory.getInstance().safetyString(new String[] { "id", "idTemplate", "name", "serverSideName",
  89. "title", "serverSideTitle", "class", "collision_radius", "collision_height", "level", "sex", "type",
  90. "attackrange", "hp", "mp", "hpreg", "mpreg", "str", "con", "dex", "int", "wit", "men", "exp", "sp",
  91. "patk", "pdef", "matk", "mdef", "atkspd", "aggro", "matkspd", "rhand", "lhand", "armor", "walkspd",
  92. "runspd", "faction_id", "faction_range", "isUndead", "absorb_level", "absorb_type", "ss", "bss",
  93. "ss_rate", "AI", "drop_herbs" }) + " FROM custom_npc");
  94. ResultSet npcdata = statement.executeQuery();
  95. fillNpcTable(npcdata, true);
  96. npcdata.close();
  97. statement.close();
  98. }
  99. catch (Exception e)
  100. {
  101. _log.log(Level.SEVERE, "NPCTable: Error creating custom NPC table.", e);
  102. }
  103. }
  104. try
  105. {
  106. con = L2DatabaseFactory.getInstance().getConnection();
  107. PreparedStatement statement = con.prepareStatement("SELECT npcid, skillid, level FROM npcskills");
  108. ResultSet npcskills = statement.executeQuery();
  109. L2NpcTemplate npcDat = null;
  110. L2Skill npcSkill = null;
  111. while (npcskills.next())
  112. {
  113. int mobId = npcskills.getInt("npcid");
  114. npcDat = _npcs.get(mobId);
  115. if (npcDat == null)
  116. continue;
  117. int skillId = npcskills.getInt("skillid");
  118. int level = npcskills.getInt("level");
  119. if (npcDat.race == null && skillId == 4416)
  120. {
  121. npcDat.setRace(level);
  122. continue;
  123. }
  124. npcSkill = SkillTable.getInstance().getInfo(skillId, level);
  125. if (npcSkill == null)
  126. continue;
  127. npcDat.addSkill(npcSkill);
  128. }
  129. npcskills.close();
  130. statement.close();
  131. }
  132. catch (Exception e)
  133. {
  134. _log.log(Level.SEVERE, "NPCTable: Error reading NPC skills table.", e);
  135. }
  136. try
  137. {
  138. PreparedStatement statement2 = con.prepareStatement("SELECT "
  139. + L2DatabaseFactory.getInstance().safetyString(new String[] { "mobId", "itemId", "min", "max", "category", "chance" })
  140. + " FROM droplist ORDER BY mobId, chance DESC");
  141. ResultSet dropData = statement2.executeQuery();
  142. L2DropData dropDat = null;
  143. L2NpcTemplate npcDat = null;
  144. while (dropData.next())
  145. {
  146. int mobId = dropData.getInt("mobId");
  147. npcDat = _npcs.get(mobId);
  148. if (npcDat == null)
  149. {
  150. _log.warning("NPCTable: Drop data for undefined NPC. npcId: " + mobId);
  151. continue;
  152. }
  153. dropDat = new L2DropData();
  154. dropDat.setItemId(dropData.getInt("itemId"));
  155. dropDat.setMinDrop(dropData.getInt("min"));
  156. dropDat.setMaxDrop(dropData.getInt("max"));
  157. dropDat.setChance(dropData.getInt("chance"));
  158. int category = dropData.getInt("category");
  159. npcDat.addDropData(dropDat, category);
  160. }
  161. dropData.close();
  162. statement2.close();
  163. }
  164. catch (Exception e)
  165. {
  166. _log.log(Level.SEVERE, "NPCTable: Error reading NPC dropdata. ", e);
  167. }
  168. if (Config.CUSTOM_DROPLIST_TABLE)
  169. {
  170. try
  171. {
  172. PreparedStatement statement2 = con.prepareStatement("SELECT "
  173. + L2DatabaseFactory.getInstance().safetyString(new String[] { "mobId", "itemId", "min", "max", "category",
  174. "chance" }) + " FROM custom_droplist ORDER BY mobId, chance DESC");
  175. ResultSet dropData = statement2.executeQuery();
  176. L2DropData dropDat = null;
  177. L2NpcTemplate npcDat = null;
  178. int cCount = 0;
  179. while (dropData.next())
  180. {
  181. int mobId = dropData.getInt("mobId");
  182. npcDat = _npcs.get(mobId);
  183. if (npcDat == null)
  184. {
  185. _log.warning("NPCTable: CUSTOM DROPLIST: Drop data for undefined NPC. npcId: " + mobId);
  186. continue;
  187. }
  188. dropDat = new L2DropData();
  189. dropDat.setItemId(dropData.getInt("itemId"));
  190. dropDat.setMinDrop(dropData.getInt("min"));
  191. dropDat.setMaxDrop(dropData.getInt("max"));
  192. dropDat.setChance(dropData.getInt("chance"));
  193. int category = dropData.getInt("category");
  194. npcDat.addDropData(dropDat, category);
  195. cCount++;
  196. }
  197. dropData.close();
  198. statement2.close();
  199. _log.info("CustomDropList: Added " + cCount + " custom droplist.");
  200. }
  201. catch (Exception e)
  202. {
  203. _log.log(Level.SEVERE, "NPCTable: Error reading NPC custom dropdata.", e);
  204. }
  205. }
  206. try
  207. {
  208. PreparedStatement statement3 = con.prepareStatement("SELECT "
  209. + L2DatabaseFactory.getInstance().safetyString(new String[] { "npc_id", "class_id" }) + " FROM skill_learn");
  210. ResultSet learndata = statement3.executeQuery();
  211. while (learndata.next())
  212. {
  213. int npcId = learndata.getInt("npc_id");
  214. int classId = learndata.getInt("class_id");
  215. L2NpcTemplate npc = getTemplate(npcId);
  216. if (npc == null)
  217. {
  218. _log.warning("NPCTable: Error getting NPC template ID " + npcId + " while trying to load skill trainer data.");
  219. continue;
  220. }
  221. npc.addTeachInfo(ClassId.values()[classId]);
  222. }
  223. learndata.close();
  224. statement3.close();
  225. }
  226. catch (Exception e)
  227. {
  228. _log.log(Level.SEVERE, "NPCTable: Error reading NPC trainer data.", e);
  229. }
  230. try
  231. {
  232. PreparedStatement statement4 = con.prepareStatement("SELECT "
  233. + L2DatabaseFactory.getInstance().safetyString(new String[] { "boss_id", "minion_id", "amount_min", "amount_max" })
  234. + " FROM minions");
  235. ResultSet minionData = statement4.executeQuery();
  236. L2MinionData minionDat = null;
  237. L2NpcTemplate npcDat = null;
  238. int cnt = 0;
  239. while (minionData.next())
  240. {
  241. int raidId = minionData.getInt("boss_id");
  242. npcDat = _npcs.get(raidId);
  243. if (npcDat == null)
  244. {
  245. _log.warning("Minion references undefined boss NPC. Boss NpcId: " + raidId);
  246. continue;
  247. }
  248. minionDat = new L2MinionData();
  249. minionDat.setMinionId(minionData.getInt("minion_id"));
  250. minionDat.setAmountMin(minionData.getInt("amount_min"));
  251. minionDat.setAmountMax(minionData.getInt("amount_max"));
  252. npcDat.addRaidData(minionDat);
  253. cnt++;
  254. }
  255. minionData.close();
  256. statement4.close();
  257. _log.config("NpcTable: Loaded " + cnt + " Minions.");
  258. }
  259. catch (Exception e)
  260. {
  261. _log.log(Level.SEVERE, "NPCTable: Error loading minion data.", e);
  262. }
  263. }
  264. finally
  265. {
  266. try
  267. {
  268. con.close();
  269. }
  270. catch (SQLException e)
  271. {
  272. // nothing
  273. }
  274. }
  275. _initialized = true;
  276. }
  277. private void fillNpcTable(ResultSet NpcData, boolean customData) throws Exception
  278. {
  279. while (NpcData.next())
  280. {
  281. StatsSet npcDat = new StatsSet();
  282. int id = NpcData.getInt("id");
  283. if (Config.ASSERT)
  284. assert id < 1000000;
  285. npcDat.set("npcId", id);
  286. npcDat.set("idTemplate", NpcData.getInt("idTemplate"));
  287. int level = NpcData.getInt("level");
  288. npcDat.set("level", level);
  289. npcDat.set("jClass", NpcData.getString("class"));
  290. npcDat.set("baseShldDef", 0);
  291. npcDat.set("baseShldRate", 0);
  292. npcDat.set("baseCritRate", 38);
  293. npcDat.set("name", NpcData.getString("name"));
  294. npcDat.set("serverSideName", NpcData.getBoolean("serverSideName"));
  295. //npcDat.set("name", "");
  296. npcDat.set("title", NpcData.getString("title"));
  297. npcDat.set("serverSideTitle", NpcData.getBoolean("serverSideTitle"));
  298. npcDat.set("collision_radius", NpcData.getDouble("collision_radius"));
  299. npcDat.set("collision_height", NpcData.getDouble("collision_height"));
  300. npcDat.set("sex", NpcData.getString("sex"));
  301. npcDat.set("type", NpcData.getString("type"));
  302. npcDat.set("baseAtkRange", NpcData.getInt("attackrange"));
  303. npcDat.set("rewardExp", NpcData.getInt("exp"));
  304. npcDat.set("rewardSp", NpcData.getInt("sp"));
  305. npcDat.set("basePAtkSpd", NpcData.getInt("atkspd"));
  306. npcDat.set("baseMAtkSpd", NpcData.getInt("matkspd"));
  307. npcDat.set("aggroRange", NpcData.getInt("aggro"));
  308. npcDat.set("rhand", NpcData.getInt("rhand"));
  309. npcDat.set("lhand", NpcData.getInt("lhand"));
  310. npcDat.set("armor", NpcData.getInt("armor"));
  311. npcDat.set("baseWalkSpd", NpcData.getInt("walkspd"));
  312. npcDat.set("baseRunSpd", NpcData.getInt("runspd"));
  313. // constants, until we have stats in DB
  314. npcDat.set("baseSTR", NpcData.getInt("str"));
  315. npcDat.set("baseCON", NpcData.getInt("con"));
  316. npcDat.set("baseDEX", NpcData.getInt("dex"));
  317. npcDat.set("baseINT", NpcData.getInt("int"));
  318. npcDat.set("baseWIT", NpcData.getInt("wit"));
  319. npcDat.set("baseMEN", NpcData.getInt("men"));
  320. npcDat.set("baseHpMax", NpcData.getInt("hp"));
  321. npcDat.set("baseCpMax", 0);
  322. npcDat.set("baseMpMax", NpcData.getInt("mp"));
  323. npcDat.set("baseHpReg", NpcData.getFloat("hpreg") > 0 ? NpcData.getFloat("hpreg") : 1.5 + ((level - 1) / 10.0));
  324. npcDat.set("baseMpReg", NpcData.getFloat("mpreg") > 0 ? NpcData.getFloat("mpreg") : 0.9 + 0.3 * ((level - 1) / 10.0));
  325. npcDat.set("basePAtk", NpcData.getInt("patk"));
  326. npcDat.set("basePDef", NpcData.getInt("pdef"));
  327. npcDat.set("baseMAtk", NpcData.getInt("matk"));
  328. npcDat.set("baseMDef", NpcData.getInt("mdef"));
  329. npcDat.set("factionId", NpcData.getString("faction_id"));
  330. npcDat.set("factionRange", NpcData.getInt("faction_range"));
  331. npcDat.set("isUndead", NpcData.getString("isUndead"));
  332. npcDat.set("absorb_level", NpcData.getString("absorb_level"));
  333. npcDat.set("absorb_type", NpcData.getString("absorb_type"));
  334. npcDat.set("ss", NpcData.getInt("ss"));
  335. npcDat.set("bss", NpcData.getInt("bss"));
  336. npcDat.set("ssRate", NpcData.getInt("ss_rate"));
  337. npcDat.set("AI", NpcData.getString("AI"));
  338. npcDat.set("drop_herbs", Boolean.valueOf(NpcData.getString("drop_herbs")));
  339. L2NpcTemplate template = new L2NpcTemplate(npcDat);
  340. template.addVulnerability(Stats.BOW_WPN_VULN, 1);
  341. template.addVulnerability(Stats.CROSSBOW_WPN_VULN, 1);
  342. template.addVulnerability(Stats.BLUNT_WPN_VULN, 1);
  343. template.addVulnerability(Stats.DAGGER_WPN_VULN, 1);
  344. _npcs.put(id, template);
  345. }
  346. if (!customData)
  347. _log.config("NpcTable: Loaded " + _npcs.size() + " NPC templates.");
  348. else
  349. _log.config("NpcTable: Loaded " + _npcs.size() + " custom NPC templates.");
  350. }
  351. public void reloadNpc(int id)
  352. {
  353. Connection con = null;
  354. try
  355. {
  356. // save a copy of the old data
  357. L2NpcTemplate old = getTemplate(id);
  358. Map<Integer, L2Skill> skills = new FastMap<Integer, L2Skill>();
  359. if (old.getSkills() != null)
  360. skills.putAll(old.getSkills());
  361. FastList<L2DropCategory> categories = new FastList<L2DropCategory>();
  362. if (old.getDropData() != null)
  363. categories.addAll(old.getDropData());
  364. ClassId[] classIds = null;
  365. if (old.getTeachInfo() != null)
  366. classIds = old.getTeachInfo().clone();
  367. List<L2MinionData> minions = new FastList<L2MinionData>();
  368. if (old.getMinionData() != null)
  369. minions.addAll(old.getMinionData());
  370. // reload the NPC base data
  371. con = L2DatabaseFactory.getInstance().getConnection();
  372. PreparedStatement st = con.prepareStatement("SELECT "
  373. + L2DatabaseFactory.getInstance().safetyString(new String[] { "id", "idTemplate", "name", "serverSideName", "title",
  374. "serverSideTitle", "class", "collision_radius", "collision_height", "level", "sex", "type", "attackrange",
  375. "hp", "mp", "hpreg", "mpreg", "str", "con", "dex", "int", "wit", "men", "exp", "sp", "patk", "pdef", "matk",
  376. "mdef", "atkspd", "aggro", "matkspd", "rhand", "lhand", "armor", "walkspd", "runspd", "faction_id",
  377. "faction_range", "isUndead", "absorb_level", "absorb_type", "ss", "bss", "ss_rate", "AI", "drop_herbs" })
  378. + " FROM npc WHERE id=?");
  379. st.setInt(1, id);
  380. ResultSet rs = st.executeQuery();
  381. fillNpcTable(rs, false);
  382. if (Config.CUSTOM_NPC_TABLE) // reload certain NPCs
  383. {
  384. st = con.prepareStatement("SELECT "
  385. + L2DatabaseFactory.getInstance().safetyString(new String[] { "id", "idTemplate", "name", "serverSideName",
  386. "title", "serverSideTitle", "class", "collision_radius", "collision_height", "level", "sex", "type",
  387. "attackrange", "hp", "mp", "hpreg", "mpreg", "str", "con", "dex", "int", "wit", "men", "exp", "sp", "patk",
  388. "pdef", "matk", "mdef", "atkspd", "aggro", "matkspd", "rhand", "lhand", "armor", "walkspd", "runspd",
  389. "faction_id", "faction_range", "isUndead", "absorb_level", "absorb_type", "ss", "bss", "ss_rate", "AI",
  390. "drop_herbs" }) + " FROM custom_npc WHERE id=?");
  391. rs = st.executeQuery();
  392. fillNpcTable(rs, true);
  393. }
  394. rs.close();
  395. st.close();
  396. // restore additional data from saved copy
  397. L2NpcTemplate created = getTemplate(id);
  398. for (L2Skill skill : skills.values())
  399. created.addSkill(skill);
  400. if (classIds != null)
  401. for (ClassId classId : classIds)
  402. created.addTeachInfo(classId);
  403. for (L2MinionData minion : minions)
  404. created.addRaidData(minion);
  405. }
  406. catch (Exception e)
  407. {
  408. _log.warning("NPCTable: Could not reload data for NPC " + id + ": " + e);
  409. }
  410. finally
  411. {
  412. try
  413. {
  414. con.close();
  415. }
  416. catch (Exception e)
  417. {
  418. }
  419. }
  420. }
  421. // just wrapper
  422. public void reloadAllNpc()
  423. {
  424. restoreNpcData();
  425. }
  426. public void saveNpc(StatsSet npc)
  427. {
  428. Connection con = null;
  429. try
  430. {
  431. con = L2DatabaseFactory.getInstance().getConnection();
  432. Map<String, Object> set = npc.getSet();
  433. int length = 0;
  434. for (Object obj : set.keySet())
  435. {
  436. // 15 is just guessed npc name length
  437. length += ((String) obj).length() + 7 + 15;
  438. }
  439. final StringBuilder sbValues = new StringBuilder(length);
  440. for (Object obj : set.keySet())
  441. {
  442. final String name = (String) obj;
  443. if (!name.equalsIgnoreCase("npcId"))
  444. {
  445. if (sbValues.length() > 0)
  446. {
  447. sbValues.append(", ");
  448. }
  449. sbValues.append(name);
  450. sbValues.append(" = '");
  451. sbValues.append(set.get(name));
  452. sbValues.append('\'');
  453. }
  454. }
  455. final StringBuilder sbQuery = new StringBuilder(sbValues.length() + 28);
  456. sbQuery.append("UPDATE npc SET ");
  457. sbQuery.append(sbValues.toString());
  458. sbQuery.append(" WHERE id = ?");
  459. PreparedStatement statement = con.prepareStatement(sbQuery.toString());
  460. statement.setInt(1, npc.getInteger("npcId"));
  461. statement.execute();
  462. statement.close();
  463. }
  464. catch (Exception e)
  465. {
  466. _log.warning("NPCTable: Could not store new NPC data in database: " + e);
  467. }
  468. finally
  469. {
  470. try
  471. {
  472. con.close();
  473. }
  474. catch (Exception e)
  475. {
  476. }
  477. }
  478. }
  479. public boolean isInitialized()
  480. {
  481. return _initialized;
  482. }
  483. public void replaceTemplate(L2NpcTemplate npc)
  484. {
  485. _npcs.put(npc.npcId, npc);
  486. }
  487. public L2NpcTemplate getTemplate(int id)
  488. {
  489. return _npcs.get(id);
  490. }
  491. public L2NpcTemplate getTemplateByName(String name)
  492. {
  493. for (L2NpcTemplate npcTemplate : _npcs.values())
  494. if (npcTemplate.name.equalsIgnoreCase(name))
  495. return npcTemplate;
  496. return null;
  497. }
  498. public L2NpcTemplate[] getAllOfLevel(int lvl)
  499. {
  500. List<L2NpcTemplate> list = new FastList<L2NpcTemplate>();
  501. for (L2NpcTemplate t : _npcs.values())
  502. if (t.level == lvl)
  503. list.add(t);
  504. return list.toArray(new L2NpcTemplate[list.size()]);
  505. }
  506. public L2NpcTemplate[] getAllMonstersOfLevel(int lvl)
  507. {
  508. List<L2NpcTemplate> list = new FastList<L2NpcTemplate>();
  509. for (L2NpcTemplate t : _npcs.values())
  510. if (t.level == lvl && "L2Monster".equals(t.type))
  511. list.add(t);
  512. return list.toArray(new L2NpcTemplate[list.size()]);
  513. }
  514. public L2NpcTemplate[] getAllNpcStartingWith(String letter)
  515. {
  516. List<L2NpcTemplate> list = new FastList<L2NpcTemplate>();
  517. for (L2NpcTemplate t : _npcs.values())
  518. if (t.name.startsWith(letter) && "L2Npc".equals(t.type))
  519. list.add(t);
  520. return list.toArray(new L2NpcTemplate[list.size()]);
  521. }
  522. /**
  523. * @param classType
  524. * @return
  525. */
  526. public Set<Integer> getAllNpcOfClassType(String classType)
  527. {
  528. return null;
  529. }
  530. /**
  531. * @param class1
  532. * @return
  533. */
  534. public Set<Integer> getAllNpcOfL2jClass(Class<?> clazz)
  535. {
  536. return null;
  537. }
  538. /**
  539. * @param aiType
  540. * @return
  541. */
  542. public Set<Integer> getAllNpcOfAiType(String aiType)
  543. {
  544. return null;
  545. }
  546. @SuppressWarnings("synthetic-access")
  547. private static class SingletonHolder
  548. {
  549. protected static final NpcTable _instance = new NpcTable();
  550. }
  551. }