Advertisement
Guest User

smart_cb.diff

a guest
Jul 20th, 2012
6,933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.51 KB | None | 0 0
  1. Index: dist/game/config/SmartCB.properties
  2. ===================================================================
  3. --- dist/game/config/SmartCB.properties (revision 0)
  4. +++ dist/game/config/SmartCB.properties (working copy)
  5. @@ -0,0 +1,33 @@
  6. +# ---------------------------------------------------------------------------
  7. +# Smart CommunityBoard Settings
  8. +# ---------------------------------------------------------------------------
  9. +# This properties file is solely for the Smart CB modifications.
  10. +# The Smart CB has been created by Darule.
  11. +
  12. +# ---------------------------------------------------------------------------
  13. +# Top Players Options
  14. +# ---------------------------------------------------------------------------
  15. +# Explanation 1
  16. +# Default value 19
  17. +TopPlayerRowHeight = 19
  18. +
  19. +# Here you can specify the amount of the results that will be displayed.
  20. +# Default value 20
  21. +TopPlayerResults = 20
  22. +
  23. +# Explanation 1
  24. +# Default value 17
  25. +RaidListRowHeight = 17
  26. +
  27. +# Here you can specify the amount of the results that will be displayed.
  28. +# Default value 20 , max is 26. If you change this you have to check the Raids Pagination because some pages might be empty.
  29. +RaidListResults = 20
  30. +
  31. +# If you enable this option Raid List results will be sorted using asceding level (Smaller level raids will appear 1st)
  32. +# Default = True
  33. +RaidListSortAsc = True
  34. +
  35. +# If you enable this option on the stat page 2 rows will appear under Players Online on stats page.
  36. +# Real active players and detached players.
  37. +# Default = True
  38. +AllowRealOnlineStats = True
  39. \ No newline at end of file
  40. Index: java/com/l2jserver/Config.java
  41. ===================================================================
  42. --- java/com/l2jserver/Config.java (revision 5370)
  43. +++ java/com/l2jserver/Config.java (working copy)
  44. @@ -90,8 +90,19 @@
  45. public static final String SECURITY_CONFIG_FILE = "./config/security.properties";
  46. public static final String EMAIL_CONFIG_FILE = "./config/email.properties";
  47. public static final String CH_SIEGE_FILE = "./config/ConquerableHallSiege.properties";
  48. + public static final String SMART_CB = "./config/SmartCB.properties";
  49.  
  50. // --------------------------------------------------
  51. + // Smart Community Board Definitions
  52. + // --------------------------------------------------
  53. + public static int TOP_PLAYER_ROW_HEIGHT;
  54. + public static int TOP_PLAYER_RESULTS;
  55. + public static int RAID_LIST_ROW_HEIGHT;
  56. + public static int RAID_LIST_RESULTS;
  57. + public static boolean RAID_LIST_SORT_ASC;
  58. + public static boolean ALLOW_REAL_ONLINE_STATS;
  59. +
  60. + // --------------------------------------------------
  61. // L2J Variable Definitions
  62. // --------------------------------------------------
  63. public static boolean ALT_GAME_DELEVEL;
  64. @@ -1260,6 +1271,25 @@
  65. throw new Error("Failed to Load " + COMMUNITY_CONFIGURATION_FILE + " File.");
  66. }
  67.  
  68. + // Load Smart CB Properties file (if exists)
  69. + final File smartcb = new File(SMART_CB);
  70. + try (InputStream is = new FileInputStream(smartcb))
  71. + {
  72. + L2Properties smartCB = new L2Properties();
  73. + smartCB.load(is);
  74. + TOP_PLAYER_ROW_HEIGHT = Integer.parseInt(smartCB.getProperty("TopPlayerRowHeight", "19"));
  75. + TOP_PLAYER_RESULTS = Integer.parseInt(smartCB.getProperty("TopPlayerResults", "20"));
  76. + RAID_LIST_ROW_HEIGHT = Integer.parseInt(smartCB.getProperty("RaidListRowHeight", "18"));
  77. + RAID_LIST_RESULTS = Integer.parseInt(smartCB.getProperty("RaidListResults", "20"));
  78. + RAID_LIST_SORT_ASC = Boolean.parseBoolean(smartCB.getProperty("RaidListSortAsc", "True"));
  79. + ALLOW_REAL_ONLINE_STATS = Boolean.parseBoolean(smartCB.getProperty("AllowRealOnlineStats", "True"));
  80. + }
  81. + catch (Exception e)
  82. + {
  83. + _log.warning("Config: " + e.getMessage());
  84. + throw new Error("Failed to Load " + SMART_CB + " File.");
  85. + }
  86. +
  87. // Load Feature L2Properties file (if exists)
  88. final File feature = new File(FEATURE_CONFIG_FILE);
  89. try (InputStream is = new FileInputStream(feature))
  90. Index: java/com/l2jserver/gameserver/communitybbs/BB/Forum.java
  91. ===================================================================
  92. --- java/com/l2jserver/gameserver/communitybbs/BB/Forum.java (revision 5370)
  93. +++ java/com/l2jserver/gameserver/communitybbs/BB/Forum.java (working copy)
  94. @@ -292,7 +292,7 @@
  95. */
  96. public void vload()
  97. {
  98. - if (!_loaded)
  99. + if (_loaded == false)
  100. {
  101. load();
  102. getChildren();
  103. Index: java/com/l2jserver/gameserver/communitybbs/CastleStatus.java
  104. ===================================================================
  105. --- java/com/l2jserver/gameserver/communitybbs/CastleStatus.java (revision 0)
  106. +++ java/com/l2jserver/gameserver/communitybbs/CastleStatus.java (working copy)
  107. @@ -0,0 +1,102 @@
  108. +package com.l2jserver.gameserver.communitybbs;
  109. +
  110. +import java.sql.Connection;
  111. +import java.sql.PreparedStatement;
  112. +import java.sql.ResultSet;
  113. +import java.text.SimpleDateFormat;
  114. +import java.util.Date;
  115. +
  116. +import com.l2jserver.L2DatabaseFactory;
  117. +
  118. +import javolution.text.TextBuilder;
  119. +
  120. +public class CastleStatus
  121. +{
  122. + private TextBuilder _playerList = new TextBuilder();
  123. +
  124. + public CastleStatus()
  125. + {
  126. + loadFromDB();
  127. + }
  128. +
  129. + @SuppressWarnings("null")
  130. + private void loadFromDB()
  131. + {
  132. + Connection con = null;
  133. +
  134. + try
  135. + {
  136. + con = L2DatabaseFactory.getInstance().getConnection();
  137. +
  138. + for (int i = 1; i < 9; i++)
  139. + {
  140. + PreparedStatement statement = con.prepareStatement("SELECT clan_name, clan_level FROM clan_data WHERE hasCastle=" + i + ";");
  141. + ResultSet result = statement.executeQuery();
  142. +
  143. + PreparedStatement statement2 = con.prepareStatement("SELECT name, siegeDate, taxPercent FROM castle WHERE id=" + i + ";");
  144. + ResultSet result2 = statement2.executeQuery();
  145. +
  146. + while (result.next())
  147. + {
  148. + String owner = result.getString("clan_name");
  149. + int level = result.getInt("clan_level");
  150. +
  151. + while (result2.next())
  152. + {
  153. + String name = result2.getString("name");
  154. + long someLong = result2.getLong("siegeDate");
  155. + int tax = result2.getInt("taxPercent");
  156. + Date anotherDate = new Date(someLong);
  157. + String DATE_FORMAT = "dd-MMM-yyyy HH:mm";
  158. + SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
  159. +
  160. + addCastleToList(name, owner, level, tax, sdf.format(anotherDate));
  161. + }
  162. +
  163. + result2.close();
  164. + statement2.close();
  165. + }
  166. +
  167. + result.close();
  168. + statement.close();
  169. + }
  170. + }
  171. +
  172. + catch (Exception e)
  173. + {
  174. + e.printStackTrace();
  175. + }
  176. +
  177. + finally
  178. + {
  179. + try
  180. + {
  181. + con.close();
  182. + }
  183. + catch (Exception e)
  184. + {
  185. + }
  186. + }
  187. + }
  188. +
  189. + private void addCastleToList(String name, String owner, int level, int tax, String siegeDate)
  190. + {
  191. + _playerList.append("<table border=0 cellspacing=0 cellpadding=2 width=750>");
  192. + _playerList.append("<tr>");
  193. + _playerList.append("<td FIXWIDTH=10></td>");
  194. + _playerList.append("<td FIXWIDTH=100>" + name + "</td>");
  195. + _playerList.append("<td FIXWIDTH=100>" + owner + "</td>");
  196. + _playerList.append("<td FIXWIDTH=80>" + level + "</td>");
  197. + _playerList.append("<td FIXWIDTH=40>" + tax + "</td>");
  198. + _playerList.append("<td FIXWIDTH=180>" + siegeDate + "</td>");
  199. + _playerList.append("<td FIXWIDTH=5></td>");
  200. + _playerList.append("</tr>");
  201. + _playerList.append("</table>");
  202. + _playerList.append("<img src=\"L2UI.Squaregray\" width=\"740\" height=\"1\">");
  203. + }
  204. +
  205. + public String loadCastleList()
  206. + {
  207. + return _playerList.toString();
  208. + }
  209. +}
  210. Index: java/com/l2jserver/gameserver/communitybbs/ClanList.java
  211. ===================================================================
  212. --- java/com/l2jserver/gameserver/communitybbs/ClanList.java (revision 0)
  213. +++ java/com/l2jserver/gameserver/communitybbs/ClanList.java (working copy)
  214. @@ -0,0 +1,116 @@
  215. +package com.l2jserver.gameserver.communitybbs;
  216. +
  217. +import com.l2jserver.L2DatabaseFactory;
  218. +import java.sql.Connection;
  219. +import java.sql.PreparedStatement;
  220. +import java.sql.ResultSet;
  221. +import javolution.text.TextBuilder;
  222. +
  223. +public class ClanList
  224. +{
  225. + private TextBuilder _clanList = new TextBuilder();
  226. +
  227. + public ClanList(int type)
  228. + {
  229. + loadFromDB(type);
  230. + }
  231. +
  232. + private void loadFromDB(int type)
  233. + {
  234. + Connection con = null;
  235. + int stpoint = 0;
  236. + int results = 20;
  237. + String castlename = "";
  238. + String allystatus = "";
  239. + String leadername = "";
  240. + for (int count = 1; count != type; count++)
  241. + {
  242. + stpoint += 20;
  243. + }
  244. +
  245. + try
  246. + {
  247. + con = L2DatabaseFactory.getInstance().getConnection();
  248. + PreparedStatement statement = con.prepareStatement("SELECT clan_id, clan_name, ally_name, leader_id, clan_level, reputation_score, hasCastle, ally_id FROM clan_data ORDER BY `clan_level` desc Limit " + stpoint + ", " + results);
  249. + ResultSet result = statement.executeQuery();
  250. + int pos = 0;
  251. +
  252. + while (result.next())
  253. + {
  254. + int clanid = result.getInt("leader_id");
  255. + String clan = result.getString("clan_name");
  256. + String ally = result.getString("ally_name");
  257. + int clanleader = result.getInt("leader_id");
  258. + int clanlevel = result.getInt("clan_level");
  259. + int reputation = result.getInt("reputation_score");
  260. + int hascastle = result.getInt("hasCastle");
  261. + int allyid = result.getInt("ally_id");
  262. + if (allyid != 0)
  263. + {
  264. + if (allyid == clanid)
  265. + allystatus = "Alliance Leader";
  266. + allystatus = "Affiliated Clan";
  267. + }
  268. + else
  269. + {
  270. + allystatus = "-";
  271. + ally = "[no-ally]";
  272. + }
  273. + if (hascastle != 0)
  274. + {
  275. + PreparedStatement statement2 = con.prepareStatement("SELECT name FROM castle WHERE id=" + hascastle);
  276. + ResultSet result2 = statement2.executeQuery();
  277. + if (result2.next())
  278. + castlename = result2.getString("name");
  279. + result2.close();
  280. + statement2.close();
  281. + }
  282. + else
  283. + castlename = "[none]";
  284. + PreparedStatement statement3 = con.prepareStatement("SELECT char_name FROM characters WHERE charId=" + clanleader);
  285. + ResultSet result3 = statement3.executeQuery();
  286. +
  287. + if (result3.next())
  288. + leadername = result3.getString("char_name");
  289. + result3.close();
  290. + statement3.close();
  291. + pos++;
  292. + addClanToList(pos, clan, ally, leadername, clanlevel, reputation, castlename, allystatus);
  293. + }
  294. + result.close();
  295. + statement.close();
  296. + }
  297. + catch (Exception e)
  298. + {
  299. + e.printStackTrace();
  300. + }
  301. + finally
  302. + {
  303. + L2DatabaseFactory.close(con);
  304. + }
  305. + }
  306. +
  307. + private void addClanToList(int pos, String clan, String ally, String leadername, int clanlevel, int reputation, String castlename, String allystatus)
  308. + {
  309. + _clanList.append("<table border=0 cellspacing=0 cellpadding=2 width=760>");
  310. + _clanList.append("<tr>");
  311. + _clanList.append("<td FIXWIDTH=5></td>");
  312. + _clanList.append("<td FIXWIDTH=20>" + pos + "</td>");
  313. + _clanList.append("<td FIXWIDTH=90>" + clan + "</td>");
  314. + _clanList.append("<td FIXWIDTH=90>" + ally + "</td>");
  315. + _clanList.append("<td FIXWIDTH=85>" + leadername + "</td>");
  316. + _clanList.append("<td FIXWIDTH=45 align=center>" + clanlevel + "</td>");
  317. + _clanList.append("<td FIXWIDTH=70 align=center>" + reputation + "</td>");
  318. + _clanList.append("<td FIXWIDTH=50 align=center>" + castlename + "</td>");
  319. + _clanList.append("<td FIXWIDTH=70 align=center>" + allystatus + "</td>");
  320. + _clanList.append("<td FIXWIDTH=5></td>");
  321. + _clanList.append("</tr>");
  322. + _clanList.append("</table>");
  323. + _clanList.append("<img src=\"L2UI.Squaregray\" width=\"740\" height=\"1\">");
  324. + }
  325. +
  326. + public String loadClanList()
  327. + {
  328. + return _clanList.toString();
  329. + }
  330. +}
  331. Index: java/com/l2jserver/gameserver/communitybbs/CommunityBoard.java
  332. ===================================================================
  333. --- java/com/l2jserver/gameserver/communitybbs/CommunityBoard.java (revision 5370)
  334. +++ java/com/l2jserver/gameserver/communitybbs/CommunityBoard.java (working copy)
  335. @@ -27,6 +27,10 @@
  336.  
  337. public class CommunityBoard
  338. {
  339. + private CommunityBoard()
  340. + {
  341. + }
  342. +
  343. public static CommunityBoard getInstance()
  344. {
  345. return SingletonHolder._instance;
  346. @@ -144,6 +148,7 @@
  347. }
  348. }
  349.  
  350. + @SuppressWarnings("synthetic-access")
  351. private static class SingletonHolder
  352. {
  353. protected static final CommunityBoard _instance = new CommunityBoard();
  354. Index: java/com/l2jserver/gameserver/communitybbs/GrandBossList.java
  355. ===================================================================
  356. --- java/com/l2jserver/gameserver/communitybbs/GrandBossList.java (revision 0)
  357. +++ java/com/l2jserver/gameserver/communitybbs/GrandBossList.java (working copy)
  358. @@ -0,0 +1,84 @@
  359. +package com.l2jserver.gameserver.communitybbs;
  360. +
  361. +import com.l2jserver.L2DatabaseFactory;
  362. +import java.sql.Connection;
  363. +import java.sql.PreparedStatement;
  364. +import java.sql.ResultSet;
  365. +import javolution.text.TextBuilder;
  366. +
  367. +public class GrandBossList
  368. +{
  369. + private TextBuilder _GrandBossList = new TextBuilder();
  370. +
  371. + public GrandBossList()
  372. + {
  373. + loadFromDB();
  374. + }
  375. +
  376. + private void loadFromDB()
  377. + {
  378. + Connection con = null;
  379. + int pos = 0;
  380. +
  381. + try
  382. + {
  383. + con = L2DatabaseFactory.getInstance().getConnection();
  384. + PreparedStatement statement = con.prepareStatement("SELECT boss_id, status FROM grandboss_data");
  385. + ResultSet result = statement.executeQuery();
  386. +
  387. + nextnpc:
  388. + while (result.next())
  389. + {
  390. + int npcid = result.getInt("boss_id");
  391. + int status = result.getInt("status");
  392. + if (npcid == 29066 || npcid == 29067 || npcid == 29068 || npcid == 29118)
  393. + continue nextnpc;
  394. +
  395. + PreparedStatement statement2 = con.prepareStatement("SELECT name FROM npc WHERE id=" + npcid);
  396. + ResultSet result2 = statement2.executeQuery();
  397. +
  398. + while (result2.next())
  399. + {
  400. + pos++;
  401. + boolean rstatus = false;
  402. + if (status == 0)
  403. + rstatus = true;
  404. + String npcname = result2.getString("name");
  405. + addGrandBossToList(pos, npcname, rstatus);
  406. + }
  407. + result2.close();
  408. + statement2.close();
  409. + }
  410. +
  411. + result.close();
  412. + statement.close();
  413. + }
  414. + catch (Exception e)
  415. + {
  416. + e.printStackTrace();
  417. + }
  418. + finally
  419. + {
  420. + L2DatabaseFactory.close(con);
  421. + }
  422. + }
  423. +
  424. + private void addGrandBossToList(int pos, String npcname, boolean rstatus)
  425. + {
  426. + _GrandBossList.append("<table border=0 cellspacing=0 cellpadding=2>");
  427. + _GrandBossList.append("<tr>");
  428. + _GrandBossList.append("<td FIXWIDTH=5></td>");
  429. + _GrandBossList.append("<td FIXWIDTH=50>" + pos + "</td>");
  430. + _GrandBossList.append("<td FIXWIDTH=130>" + npcname + "</td>");
  431. + _GrandBossList.append("<td FIXWIDTH=60 align=center>" + ((rstatus) ? "<font color=99FF00>Alive</font>" : "<font color=CC0000>Dead</font>") + "</td>");
  432. + _GrandBossList.append("<td FIXWIDTH=5></td>");
  433. + _GrandBossList.append("</tr>");
  434. + _GrandBossList.append("</table>");
  435. + _GrandBossList.append("<img src=\"L2UI.Squaregray\" width=\"250\" height=\"1\">");
  436. + }
  437. +
  438. + public String loadGrandBossList()
  439. + {
  440. + return _GrandBossList.toString();
  441. + }
  442. +}
  443. Index: java/com/l2jserver/gameserver/communitybbs/HeroeList.java
  444. ===================================================================
  445. --- java/com/l2jserver/gameserver/communitybbs/HeroeList.java (revision 0)
  446. +++ java/com/l2jserver/gameserver/communitybbs/HeroeList.java (working copy)
  447. @@ -0,0 +1,197 @@
  448. +package com.l2jserver.gameserver.communitybbs;
  449. +
  450. +import java.sql.PreparedStatement;
  451. +import java.sql.ResultSet;
  452. +import java.util.Map;
  453. +
  454. +import com.l2jserver.L2DatabaseFactory;
  455. +
  456. +import javolution.text.TextBuilder;
  457. +import javolution.util.FastMap;
  458. +
  459. +public class HeroeList
  460. +{
  461. + private int _posId;
  462. + private TextBuilder _heroeList = new TextBuilder();
  463. +
  464. + public HeroeList()
  465. + {
  466. + loadFromDB();
  467. + }
  468. +
  469. + @SuppressWarnings("null")
  470. + private void loadFromDB()
  471. + {
  472. + java.sql.Connection con = null;
  473. + try
  474. + {
  475. + _posId = 0;
  476. + con = L2DatabaseFactory.getInstance().getConnection();
  477. + PreparedStatement statement = con.prepareStatement("SELECT h.count, h.played, ch.char_name, ch.base_class, ch.online, cl.clan_name, cl.ally_name FROM heroes h LEFT JOIN characters ch ON ch.charId=h.charId LEFT OUTER JOIN clan_data cl ON cl.clan_id=ch.clanid ORDER BY h.count DESC, ch.char_name ASC LIMIT 20");
  478. +
  479. + ResultSet result = statement.executeQuery();
  480. +
  481. + while (result.next())
  482. + {
  483. + boolean status = false;
  484. + _posId = _posId + 1;
  485. +
  486. + if (result.getInt("online") == 1)
  487. + status = true;
  488. +
  489. + addPlayerToList(_posId, result.getInt("count"), result.getInt("played"), result.getString("char_name"), result.getInt("base_class"), result.getString("clan_name"), result.getString("ally_name"), status);
  490. + }
  491. + result.close();
  492. + statement.close();
  493. + }
  494. + catch (Exception e)
  495. + {
  496. + e.printStackTrace();
  497. + }
  498. + finally
  499. + {
  500. + try
  501. + {
  502. + con.close();
  503. + }
  504. + catch (Exception e)
  505. + {
  506. + }
  507. + }
  508. + }
  509. +
  510. + public String loadHeroeList()
  511. + {
  512. + return _heroeList.toString();
  513. + }
  514. +
  515. + private void addPlayerToList(int objId, int count, int played, String name, int ChrClass, String clan, String ally, boolean isOnline)
  516. + {
  517. + _heroeList.append("<table border=0 cellspacing=0 cellpadding=2 width=750>");
  518. + _heroeList.append("<tr>");
  519. + _heroeList.append("<td FIXWIDTH=10></td>");
  520. + _heroeList.append("<td FIXWIDTH=40>" + objId + ".</td>");
  521. + _heroeList.append("<td FIXWIDTH=150>" + name + "</td>");
  522. + _heroeList.append("<td FIXWIDTH=160>" + className(ChrClass) + "</td>");
  523. + _heroeList.append("<td FIXWIDTH=80>" + count + "</td>");
  524. + _heroeList.append("<td FIXWIDTH=80>" + played + "</td>");
  525. + _heroeList.append("<td FIXWIDTH=160>" + clan + "</td>");
  526. + _heroeList.append("<td FIXWIDTH=160>" + ally + "</td>");
  527. + _heroeList.append("<td FIXWIDTH=70>" + ((isOnline) ? "<font color=99FF00>Online</font>" : "<font color=CC0000>Offline</font>") + "</td>");
  528. + _heroeList.append("<td FIXWIDTH=5></td>");
  529. + _heroeList.append("</tr>");
  530. + _heroeList.append("</table>");
  531. + _heroeList.append("<img src=\"L2UI.Squaregray\" width=\"740\" height=\"1\">");
  532. + }
  533. +
  534. + public final static String className(int classId)
  535. + {
  536. + Map<Integer, String> classList;
  537. + classList = new FastMap<Integer, String>();
  538. + classList.put(0, "Fighter");
  539. + classList.put(1, "Warrior");
  540. + classList.put(2, "Gladiator");
  541. + classList.put(3, "Warlord");
  542. + classList.put(4, "Knight");
  543. + classList.put(5, "Paladin");
  544. + classList.put(6, "Dark Avenger");
  545. + classList.put(7, "Rogue");
  546. + classList.put(8, "Treasure Hunter");
  547. + classList.put(9, "Hawkeye");
  548. + classList.put(10, "Mage");
  549. + classList.put(11, "Wizard");
  550. + classList.put(12, "Sorcerer");
  551. + classList.put(13, "Necromancer");
  552. + classList.put(14, "Warlock");
  553. + classList.put(15, "Cleric");
  554. + classList.put(16, "Bishop");
  555. + classList.put(17, "Prophet");
  556. + classList.put(18, "Elven Fighter");
  557. + classList.put(19, "Elven Knight");
  558. + classList.put(20, "Temple Knight");
  559. + classList.put(21, "Swordsinger");
  560. + classList.put(22, "Elven Scout");
  561. + classList.put(23, "Plains Walker");
  562. + classList.put(24, "Silver Ranger");
  563. + classList.put(25, "Elven Mage");
  564. + classList.put(26, "Elven Wizard");
  565. + classList.put(27, "Spellsinger");
  566. + classList.put(28, "Elemental Summoner");
  567. + classList.put(29, "Oracle");
  568. + classList.put(30, "Elder");
  569. + classList.put(31, "Dark Fighter");
  570. + classList.put(32, "Palus Knightr");
  571. + classList.put(33, "Shillien Knight");
  572. + classList.put(34, "Bladedancer");
  573. + classList.put(35, "Assasin");
  574. + classList.put(36, "Abyss Walker");
  575. + classList.put(37, "Phantom Ranger");
  576. + classList.put(38, "Dark Mage");
  577. + classList.put(39, "Dark Wizard");
  578. + classList.put(40, "Spellhowler");
  579. + classList.put(41, "Phantom Summoner");
  580. + classList.put(42, "Shillien Oracle");
  581. + classList.put(43, "Shilien Elder");
  582. + classList.put(44, "Orc Fighter");
  583. + classList.put(45, "Orc Raider");
  584. + classList.put(46, "Destroyer");
  585. + classList.put(47, "Orc Monk");
  586. + classList.put(48, "Tyrant");
  587. + classList.put(49, "Orc Mage");
  588. + classList.put(50, "Orc Shaman");
  589. + classList.put(51, "Overlord");
  590. + classList.put(52, "Warcryer");
  591. + classList.put(53, "Dwarven Fighter");
  592. + classList.put(54, "Scavenger");
  593. + classList.put(55, "Bounty Hunter");
  594. + classList.put(56, "Artisan");
  595. + classList.put(57, "Warsmith");
  596. + classList.put(88, "Duelist");
  597. + classList.put(89, "Dreadnought");
  598. + classList.put(90, "Phoenix Knight");
  599. + classList.put(91, "Hell Knight");
  600. + classList.put(92, "Sagittarius");
  601. + classList.put(93, "Adventurer");
  602. + classList.put(94, "Archmage");
  603. + classList.put(95, "Soultaker");
  604. + classList.put(96, "Arcana Lord");
  605. + classList.put(97, "Cardinal");
  606. + classList.put(98, "Hierophant");
  607. + classList.put(99, "Evas Templar");
  608. + classList.put(100, "Sword Muse");
  609. + classList.put(101, "Wind Rider");
  610. + classList.put(102, "Moonlight Sentinel");
  611. + classList.put(103, "Mystic Muse");
  612. + classList.put(104, "Elemental Master");
  613. + classList.put(105, "Evas Saint");
  614. + classList.put(106, "Shillien Templar");
  615. + classList.put(107, "Spectral Dancer");
  616. + classList.put(108, "Ghost Hunter");
  617. + classList.put(109, "Ghost Sentinel");
  618. + classList.put(110, "Storm Screamer");
  619. + classList.put(111, "Spectral Master");
  620. + classList.put(112, "Shillien Saint");
  621. + classList.put(113, "Titan");
  622. + classList.put(114, "Grand Khavatari");
  623. + classList.put(115, "Dominator");
  624. + classList.put(116, "Doomcryer");
  625. + classList.put(117, "Fortune Seeker");
  626. + classList.put(118, "Maestro");
  627. + classList.put(123, "Male Soldier");
  628. + classList.put(124, "Female Soldier");
  629. + classList.put(125, "Trooper");
  630. + classList.put(126, "Warder");
  631. + classList.put(127, "Berserker");
  632. + classList.put(128, "Male Soulbreaker");
  633. + classList.put(129, "Female Soulbreaker");
  634. + classList.put(130, "Arbalester");
  635. + classList.put(131, "Doombringer");
  636. + classList.put(132, "Male Soulhound");
  637. + classList.put(133, "Female Soulhound");
  638. + classList.put(134, "Trickster");
  639. + classList.put(135, "Inspector");
  640. + classList.put(136, "Judicator");
  641. +
  642. + return classList.get(classId);
  643. + }
  644. +}
  645. Index: java/com/l2jserver/gameserver/communitybbs/Manager/AdminBBSManager.java
  646. ===================================================================
  647. --- java/com/l2jserver/gameserver/communitybbs/Manager/AdminBBSManager.java (revision 5370)
  648. +++ java/com/l2jserver/gameserver/communitybbs/Manager/AdminBBSManager.java (working copy)
  649. @@ -27,6 +27,14 @@
  650. return SingletonHolder._instance;
  651. }
  652.  
  653. + private AdminBBSManager()
  654. + {
  655. + }
  656. +
  657. + /**
  658. + *
  659. + * @see com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
  660. + */
  661. @Override
  662. public void parsecmd(String command, L2PcInstance activeChar)
  663. {
  664. @@ -65,6 +73,7 @@
  665.  
  666. }
  667.  
  668. + @SuppressWarnings("synthetic-access")
  669. private static class SingletonHolder
  670. {
  671. protected static final AdminBBSManager _instance = new AdminBBSManager();
  672. Index: java/com/l2jserver/gameserver/communitybbs/Manager/ClanBBSManager.java
  673. ===================================================================
  674. --- java/com/l2jserver/gameserver/communitybbs/Manager/ClanBBSManager.java (revision 5370)
  675. +++ java/com/l2jserver/gameserver/communitybbs/Manager/ClanBBSManager.java (working copy)
  676. @@ -24,6 +24,10 @@
  677.  
  678. public class ClanBBSManager extends BaseBBSManager
  679. {
  680. + private ClanBBSManager()
  681. + {
  682. + }
  683. +
  684. public static ClanBBSManager getInstance()
  685. {
  686. return SingletonHolder._instance;
  687. @@ -274,6 +278,7 @@
  688. clanhome(activeChar, activeChar.getClan().getClanId());
  689. }
  690.  
  691. + @SuppressWarnings("synthetic-access")
  692. private static class SingletonHolder
  693. {
  694. protected static final ClanBBSManager _instance = new ClanBBSManager();
  695. Index: java/com/l2jserver/gameserver/communitybbs/Manager/ForumsBBSManager.java
  696. ===================================================================
  697. --- java/com/l2jserver/gameserver/communitybbs/Manager/ForumsBBSManager.java (revision 5370)
  698. +++ java/com/l2jserver/gameserver/communitybbs/Manager/ForumsBBSManager.java (working copy)
  699. @@ -41,7 +41,7 @@
  700. return SingletonHolder._instance;
  701. }
  702.  
  703. - protected ForumsBBSManager()
  704. + private ForumsBBSManager()
  705. {
  706. _table = new FastList<Forum>();
  707.  
  708. @@ -157,6 +157,7 @@
  709. {
  710. }
  711.  
  712. + @SuppressWarnings("synthetic-access")
  713. private static class SingletonHolder
  714. {
  715. protected static final ForumsBBSManager _instance = new ForumsBBSManager();
  716. Index: java/com/l2jserver/gameserver/communitybbs/Manager/PostBBSManager.java
  717. ===================================================================
  718. --- java/com/l2jserver/gameserver/communitybbs/Manager/PostBBSManager.java (revision 5370)
  719. +++ java/com/l2jserver/gameserver/communitybbs/Manager/PostBBSManager.java (working copy)
  720. @@ -32,10 +32,16 @@
  721.  
  722. public class PostBBSManager extends BaseBBSManager
  723. {
  724. +
  725. private Map<Topic, Post> _postByTopic;
  726.  
  727. - protected PostBBSManager()
  728. + public static PostBBSManager getInstance()
  729. {
  730. + return SingletonHolder._instance;
  731. + }
  732. +
  733. + private PostBBSManager()
  734. + {
  735. _postByTopic = new FastMap<Topic, Post>();
  736. }
  737.  
  738. @@ -45,7 +51,7 @@
  739. post = _postByTopic.get(t);
  740. if (post == null)
  741. {
  742. - post = new Post(t);
  743. + post = load(t);
  744. _postByTopic.put(t, post);
  745. }
  746. return post;
  747. @@ -67,6 +73,17 @@
  748. }
  749. }
  750.  
  751. + /**
  752. + * @param t
  753. + * @return
  754. + */
  755. + private Post load(Topic t)
  756. + {
  757. + Post p;
  758. + p = new Post(t);
  759. + return p;
  760. + }
  761. +
  762. @Override
  763. public void parsecmd(String command, L2PcInstance activeChar)
  764. {
  765. @@ -288,34 +305,31 @@
  766. }
  767. else
  768. {
  769. - final Post p = getGPosttByTopic(t);
  770. + CPost cp = null;
  771. + Post p = getGPosttByTopic(t);
  772. if (p != null)
  773. {
  774. - final CPost cp = p.getCPost(idp);
  775. - if (cp == null)
  776. - {
  777. - ShowBoard sb = new ShowBoard("<html><body><br><br><center>the post: " + idp
  778. - + " does not exist !</center><br><br></body></html>", "101");
  779. - activeChar.sendPacket(sb);
  780. - activeChar.sendPacket(new ShowBoard(null, "102"));
  781. - activeChar.sendPacket(new ShowBoard(null, "103"));
  782. - }
  783. - else
  784. - {
  785. - p.getCPost(idp).postTxt = ar4;
  786. - p.updatetxt(idp);
  787. - parsecmd("_bbsposts;read;" + f.getID() + ";" + t.getID(), activeChar);
  788. - }
  789. + cp = p.getCPost(idp);
  790. }
  791. + if (cp == null)
  792. + {
  793. + ShowBoard sb = new ShowBoard("<html><body><br><br><center>the post: " + idp
  794. + + " does not exist !</center><br><br></body></html>", "101");
  795. + activeChar.sendPacket(sb);
  796. + activeChar.sendPacket(new ShowBoard(null, "102"));
  797. + activeChar.sendPacket(new ShowBoard(null, "103"));
  798. + }
  799. + else
  800. + {
  801. + p.getCPost(idp).postTxt = ar4;
  802. + p.updatetxt(idp);
  803. + parsecmd("_bbsposts;read;" + f.getID() + ";" + t.getID(), activeChar);
  804. + }
  805. }
  806. }
  807. }
  808.  
  809. - public static PostBBSManager getInstance()
  810. - {
  811. - return SingletonHolder._instance;
  812. - }
  813. -
  814. + @SuppressWarnings("synthetic-access")
  815. private static class SingletonHolder
  816. {
  817. protected static final PostBBSManager _instance = new PostBBSManager();
  818. Index: java/com/l2jserver/gameserver/communitybbs/Manager/RegionBBSManager.java
  819. ===================================================================
  820. --- java/com/l2jserver/gameserver/communitybbs/Manager/RegionBBSManager.java (revision 5370)
  821. +++ java/com/l2jserver/gameserver/communitybbs/Manager/RegionBBSManager.java (working copy)
  822. @@ -54,6 +54,10 @@
  823. }
  824. };
  825.  
  826. + private RegionBBSManager()
  827. + {
  828. + }
  829. +
  830. @Override
  831. public void parsecmd(String command, L2PcInstance activeChar)
  832. {
  833. @@ -564,6 +568,7 @@
  834. return null;
  835. }
  836.  
  837. + @SuppressWarnings("synthetic-access")
  838. private static class SingletonHolder
  839. {
  840. protected static final RegionBBSManager _instance = new RegionBBSManager();
  841. Index: java/com/l2jserver/gameserver/communitybbs/Manager/TopBBSManager.java
  842. ===================================================================
  843. --- java/com/l2jserver/gameserver/communitybbs/Manager/TopBBSManager.java (revision 5370)
  844. +++ java/com/l2jserver/gameserver/communitybbs/Manager/TopBBSManager.java (working copy)
  845. @@ -1,66 +1,128 @@
  846. -/*
  847. - * This program is free software: you can redistribute it and/or modify it under
  848. - * the terms of the GNU General Public License as published by the Free Software
  849. - * Foundation, either version 3 of the License, or (at your option) any later
  850. - * version.
  851. - *
  852. - * This program is distributed in the hope that it will be useful, but WITHOUT
  853. - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  854. - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  855. - * details.
  856. - *
  857. - * You should have received a copy of the GNU General Public License along with
  858. - * this program. If not, see <http://www.gnu.org/licenses/>.
  859. - */
  860. package com.l2jserver.gameserver.communitybbs.Manager;
  861.  
  862. +import java.io.File;
  863. import java.util.StringTokenizer;
  864.  
  865. +import com.l2jserver.Config;
  866. +import com.l2jserver.gameserver.GameTimeController;
  867. import com.l2jserver.gameserver.cache.HtmCache;
  868. +import com.l2jserver.gameserver.communitybbs.CastleStatus;
  869. +import com.l2jserver.gameserver.communitybbs.ClanList;
  870. +import com.l2jserver.gameserver.communitybbs.GrandBossList;
  871. +import com.l2jserver.gameserver.communitybbs.HeroeList;
  872. +import com.l2jserver.gameserver.communitybbs.RaidList;
  873. +import com.l2jserver.gameserver.communitybbs.TopPlayers;
  874. +import com.l2jserver.gameserver.model.L2World;
  875. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  876. import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
  877.  
  878. -
  879. public class TopBBSManager extends BaseBBSManager
  880. {
  881. +
  882. + private TopBBSManager()
  883. + {
  884. + }
  885. +
  886. @Override
  887. public void parsecmd(String command, L2PcInstance activeChar)
  888. {
  889. - if (command.equals("_bbstop"))
  890. + String path = "data/html/CommunityBoard/";
  891. + String filepath = "";
  892. + String content = "";
  893. +
  894. + if (command.equals("_bbstop") | command.equals("_bbshome"))
  895. {
  896. - String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/index.htm");
  897. - if (content == null)
  898. - {
  899. - content = "<html><body><br><br><center>404 :File not found: 'data/html/CommunityBoard/index.htm' </center></body></html>";
  900. - }
  901. + filepath = path + "index.htm";
  902. + content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filepath);
  903. separateAndSend(content, activeChar);
  904. }
  905. - else if (command.equals("_bbshome"))
  906. - {
  907. - String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/index.htm");
  908. - if (content == null)
  909. - {
  910. - content = "<html><body><br><br><center>404 :File not found: 'data/html/CommunityBoard/index.htm' </center></body></html>";
  911. - }
  912. - separateAndSend(content, activeChar);
  913. - }
  914. else if (command.startsWith("_bbstop;"))
  915. {
  916. StringTokenizer st = new StringTokenizer(command, ";");
  917. st.nextToken();
  918. - int idp = Integer.parseInt(st.nextToken());
  919. - String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/" + idp + ".htm");
  920. - if (content == null)
  921. + String file = st.nextToken();
  922. + filepath = path + file + ".htm";
  923. + File filecom = new File(filepath);
  924. +
  925. + if (!(filecom.exists()))
  926. {
  927. - content = "<html><body><br><br><center>404 :File not found: 'data/html/CommunityBoard/" + idp
  928. - + ".htm' </center></body></html>";
  929. + content = "<html><body><br><br><center>The command " + command + " points to file(" + filepath + ") that NOT exists.</center></body></html>";
  930. + separateAndSend(content, activeChar);
  931. + return;
  932. }
  933. + content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filepath);
  934. +
  935. + if (content.isEmpty())
  936. + content = "<html><body><br><br><center>Content Empty: The command " + command + " points to an invalid or empty html file(" + filepath + ").</center></body></html>";
  937. +
  938. + switch (file)
  939. + {
  940. + case "toppvp":
  941. + TopPlayers pvp = new TopPlayers(file);
  942. + content = content.replaceAll("%toppvp%", pvp.loadTopList());
  943. + break;
  944. + case "toppk":
  945. + TopPlayers pk = new TopPlayers(file);
  946. + content = content.replaceAll("%toppk%", pk.loadTopList());
  947. + break;
  948. + case "toprbrank":
  949. + TopPlayers raid = new TopPlayers(file);
  950. + content = content.replaceAll("%toprbrank%", raid.loadTopList());
  951. + break;
  952. + case "topadena":
  953. + TopPlayers adena = new TopPlayers(file);
  954. + content = content.replaceAll("%topadena%", adena.loadTopList());
  955. + break;
  956. + case "toponline":
  957. + TopPlayers online = new TopPlayers(file);
  958. + content = content.replaceAll("%toponline%", online.loadTopList());
  959. + break;
  960. + case "heroes":
  961. + HeroeList hr = new HeroeList();
  962. + content = content.replaceAll("%heroelist%", hr.loadHeroeList());
  963. + break;
  964. + case "castle":
  965. + CastleStatus status = new CastleStatus();
  966. + content = content.replaceAll("%castle%", status.loadCastleList());
  967. + break;
  968. + case "boss":
  969. + GrandBossList gb = new GrandBossList();
  970. + content = content.replaceAll("%gboss%", gb.loadGrandBossList());
  971. + break;
  972. + case "stats":
  973. + content = content.replace("%online%", Integer.toString(L2World.getInstance().getAllPlayersCount()));
  974. + content = content.replace("%servercapacity%", Integer.toString(Config.MAXIMUM_ONLINE_USERS));
  975. + content = content.replace("%serverruntime%", getServerRunTime());
  976. + if (Config.ALLOW_REAL_ONLINE_STATS)
  977. + content = content.replace("%serveronline%", getRealOnline());
  978. + else
  979. + content = content.replace("%serveronline%", "");
  980. + break;
  981. + default:
  982. + break;
  983. +
  984. + }
  985. + if (file.startsWith("clan"))
  986. + {
  987. + int cid = Integer.parseInt(file.substring(4));
  988. + ClanList cl = new ClanList(cid);
  989. + content = content.replaceAll("%clanlist%", cl.loadClanList());
  990. + }
  991. + if (file.startsWith("raid"))
  992. + {
  993. + String rfid = file.substring(4);
  994. + RaidList rd = new RaidList(rfid);
  995. + content = content.replaceAll("%raidlist%", rd.loadRaidList());
  996. + }
  997. + if (content.isEmpty())
  998. + {
  999. + content = "<html><body><br><br><center>404 :File not found or empty: " + filepath + " your command is " + command + "</center></body></html>";
  1000. + }
  1001. separateAndSend(content, activeChar);
  1002. }
  1003. else
  1004. {
  1005. - ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command
  1006. - + " is not implemented yet</center><br><br></body></html>", "101");
  1007. + ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
  1008. activeChar.sendPacket(sb);
  1009. activeChar.sendPacket(new ShowBoard(null, "102"));
  1010. activeChar.sendPacket(new ShowBoard(null, "103"));
  1011. @@ -77,8 +139,34 @@
  1012. return SingletonHolder._instance;
  1013. }
  1014.  
  1015. + @SuppressWarnings("synthetic-access")
  1016. private static class SingletonHolder
  1017. {
  1018. protected static final TopBBSManager _instance = new TopBBSManager();
  1019. }
  1020. +
  1021. + public String getServerRunTime()
  1022. + {
  1023. + int timeSeconds = (GameTimeController.getGameTicks() - 36000) / 10;
  1024. + String timeResult = "";
  1025. + if (timeSeconds >= 86400)
  1026. + timeResult = Integer.toString(timeSeconds / 86400) + " Days " + Integer.toString((timeSeconds % 86400) / 3600) + " hours";
  1027. + else
  1028. + timeResult = Integer.toString(timeSeconds / 3600) + " Hours " + Integer.toString((timeSeconds % 3600) / 60) + " mins";
  1029. + return timeResult;
  1030. + }
  1031. +
  1032. + public String getRealOnline()
  1033. + {
  1034. + int counter = 0;
  1035. + for (L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayersArray())
  1036. + {
  1037. + if (onlinePlayer.isOnline() && (onlinePlayer.getClient() != null && !onlinePlayer.getClient().isDetached()))
  1038. + {
  1039. + counter++;
  1040. + }
  1041. + }
  1042. + String realOnline = "<tr><td fixwidth=11></td><td FIXWIDTH=280>Players Active</td><td FIXWIDTH=470><font color=26e600>" + counter + "</font></td></tr>" + "<tr><td fixwidth=11></td><td FIXWIDTH=280>Players Shops</td><td FIXWIDTH=470><font color=26e600>" + (L2World.getInstance().getAllPlayersCount() - counter) + "</font></td></tr>";
  1043. + return realOnline;
  1044. + }
  1045. }
  1046. \ No newline at end of file
  1047. Index: java/com/l2jserver/gameserver/communitybbs/Manager/TopicBBSManager.java
  1048. ===================================================================
  1049. --- java/com/l2jserver/gameserver/communitybbs/Manager/TopicBBSManager.java (revision 5370)
  1050. +++ java/com/l2jserver/gameserver/communitybbs/Manager/TopicBBSManager.java (working copy)
  1051. @@ -42,7 +42,7 @@
  1052. return SingletonHolder._instance;
  1053. }
  1054.  
  1055. - protected TopicBBSManager()
  1056. + private TopicBBSManager()
  1057. {
  1058. _table = new FastList<Topic>();
  1059. _maxId = new FastMap<Forum, Integer>().shared();
  1060. @@ -442,6 +442,7 @@
  1061. separateAndSend(html.toString(), activeChar);
  1062. }
  1063.  
  1064. + @SuppressWarnings("synthetic-access")
  1065. private static class SingletonHolder
  1066. {
  1067. protected static final TopicBBSManager _instance = new TopicBBSManager();
  1068. Index: java/com/l2jserver/gameserver/communitybbs/RaidList.java
  1069. ===================================================================
  1070. --- java/com/l2jserver/gameserver/communitybbs/RaidList.java (revision 0)
  1071. +++ java/com/l2jserver/gameserver/communitybbs/RaidList.java (working copy)
  1072. @@ -0,0 +1,101 @@
  1073. +package com.l2jserver.gameserver.communitybbs;
  1074. +
  1075. +import com.l2jserver.Config;
  1076. +import com.l2jserver.L2DatabaseFactory;
  1077. +import java.sql.Connection;
  1078. +import java.sql.PreparedStatement;
  1079. +import java.sql.ResultSet;
  1080. +import javolution.text.TextBuilder;
  1081. +
  1082. +public class RaidList
  1083. +{
  1084. + private TextBuilder _raidList = new TextBuilder();
  1085. +
  1086. + public RaidList(String rfid)
  1087. + {
  1088. + loadFromDB(rfid);
  1089. + }
  1090. +
  1091. + private void loadFromDB(String rfid)
  1092. + {
  1093. + int type = Integer.parseInt(rfid);
  1094. + Connection con = null;
  1095. + int stpoint = 0;
  1096. + int pos = 0;
  1097. + String sort = "";
  1098. + if (Config.RAID_LIST_SORT_ASC)
  1099. + sort = "ASC";
  1100. + else
  1101. + sort = "DESC";
  1102. + for (int count = 1; count != type; count++)
  1103. + {
  1104. + stpoint += Config.RAID_LIST_RESULTS;
  1105. + }
  1106. +
  1107. +
  1108. + try
  1109. + {
  1110. + con = L2DatabaseFactory.getInstance().getConnection();
  1111. + PreparedStatement statement = con.prepareStatement("SELECT id, name, level FROM npc WHERE type='L2RaidBoss' AND EXISTS (SELECT * FROM raidboss_spawnlist WHERE raidboss_spawnlist.boss_id = npc.id) ORDER BY `level` " + sort + " Limit " + stpoint + ", " + Config.RAID_LIST_RESULTS);
  1112. + ResultSet result = statement.executeQuery();
  1113. + pos = stpoint;
  1114. +
  1115. + while (result.next())
  1116. + {
  1117. + int npcid = result.getInt("id");
  1118. + String npcname = result.getString("name");
  1119. + int rlevel = result.getInt("level");
  1120. + PreparedStatement statement2 = con.prepareStatement("SELECT respawn_time, respawn_min_delay, respawn_max_delay FROM raidboss_spawnlist WHERE boss_id=" + npcid);
  1121. + ResultSet result2 = statement2.executeQuery();
  1122. +
  1123. + while (result2.next())
  1124. + {
  1125. + pos++;
  1126. + boolean rstatus = false;
  1127. + long respawn = result2.getLong("respawn_time");
  1128. + if (respawn == 0)
  1129. + rstatus = true;
  1130. + int mindelay = result2.getInt("respawn_min_delay");
  1131. + int maxdelay = result2.getInt("respawn_max_delay");
  1132. + mindelay = mindelay / 60 / 60;
  1133. + maxdelay = maxdelay / 60 / 60;
  1134. + addRaidToList(pos, npcname, rlevel, mindelay, maxdelay, rstatus);
  1135. + }
  1136. + result2.close();
  1137. + statement2.close();
  1138. + }
  1139. +
  1140. + result.close();
  1141. + statement.close();
  1142. + }
  1143. + catch (Exception e)
  1144. + {
  1145. + e.printStackTrace();
  1146. + }
  1147. + finally
  1148. + {
  1149. + L2DatabaseFactory.close(con);
  1150. + }
  1151. + }
  1152. +
  1153. + private void addRaidToList(int pos, String npcname, int rlevel, int mindelay, int maxdelay, boolean rstatus)
  1154. + {
  1155. + _raidList.append("<table border=0 cellspacing=0 cellpadding=2 width=750 height="+Config.RAID_LIST_ROW_HEIGHT+">");
  1156. + _raidList.append("<tr>");
  1157. + _raidList.append("<td FIXWIDTH=5></td>");
  1158. + _raidList.append("<td FIXWIDTH=20>" + pos + "</td>");
  1159. + _raidList.append("<td FIXWIDTH=270>" + npcname + "</td>");
  1160. + _raidList.append("<td FIXWIDTH=50>" + rlevel + "</td>");
  1161. + _raidList.append("<td FIXWIDTH=120 align=center>" + mindelay + " - " + maxdelay + "</td>");
  1162. + _raidList.append("<td FIXWIDTH=50 align=center>" + ((rstatus) ? "<font color=99FF00>Alive</font>" : "<font color=CC0000>Dead</font>") + "</td>");
  1163. + _raidList.append("<td FIXWIDTH=5></td>");
  1164. + _raidList.append("</tr>");
  1165. + _raidList.append("</table>");
  1166. + _raidList.append("<img src=\"L2UI.Squaregray\" width=\"740\" height=\"1\">");
  1167. + }
  1168. +
  1169. + public String loadRaidList()
  1170. + {
  1171. + return _raidList.toString();
  1172. + }
  1173. +}
  1174. Index: java/com/l2jserver/gameserver/communitybbs/TopPlayers.java
  1175. ===================================================================
  1176. --- java/com/l2jserver/gameserver/communitybbs/TopPlayers.java (revision 0)
  1177. +++ java/com/l2jserver/gameserver/communitybbs/TopPlayers.java (working copy)
  1178. @@ -0,0 +1,243 @@
  1179. +package com.l2jserver.gameserver.communitybbs;
  1180. +
  1181. +import java.sql.Connection;
  1182. +import java.sql.PreparedStatement;
  1183. +import java.sql.ResultSet;
  1184. +import java.util.Map;
  1185. +
  1186. +import javolution.text.TextBuilder;
  1187. +import javolution.util.FastMap;
  1188. +
  1189. +import com.l2jserver.Config;
  1190. +import com.l2jserver.L2DatabaseFactory;
  1191. +
  1192. +public class TopPlayers
  1193. +{
  1194. + private int pos;
  1195. + private TextBuilder _topList = new TextBuilder();
  1196. + String sort = "";
  1197. +
  1198. + public TopPlayers(String file)
  1199. + {
  1200. + loadDB(file);
  1201. + }
  1202. +
  1203. + @SuppressWarnings("null")
  1204. + private void loadDB(String file)
  1205. + {
  1206. + Connection con = null;
  1207. +
  1208. + switch (file)
  1209. + {
  1210. + case "toppvp":
  1211. + sort = "pvpkills";
  1212. + break;
  1213. + case "toppk":
  1214. + sort = "pkkills";
  1215. + break;
  1216. + case "topadena":
  1217. + sort = "SUM(it.count)";
  1218. + break;
  1219. + case "toprbrank":
  1220. + sort = "SUM(chr.points)";
  1221. + break;
  1222. + case "toponline":
  1223. + sort = "onlinetime";
  1224. + break;
  1225. + default:
  1226. + break;
  1227. +
  1228. + }
  1229. +
  1230. + try
  1231. + {
  1232. + pos = 0;
  1233. + con = L2DatabaseFactory.getInstance().getConnection();
  1234. + PreparedStatement statement = con.prepareStatement("SELECT SUM(chr.points), SUM(it.count), ch.char_name, ch.pkkills, ch.pvpkills, ch.onlinetime, ch.base_class, ch.online FROM characters ch LEFT JOIN character_raid_points chr ON ch.charId=chr.charId LEFT OUTER JOIN items it ON ch.charId=it.owner_id WHERE item_id=57 GROUP BY ch.charId ORDER BY " + sort + " DESC LIMIT " + Config.TOP_PLAYER_RESULTS);
  1235. +
  1236. + ResultSet result = statement.executeQuery();
  1237. +
  1238. + while (result.next())
  1239. + {
  1240. + boolean status = false;
  1241. + pos++;
  1242. +
  1243. + if (result.getInt("online") == 1)
  1244. + status = true;
  1245. + String timeon = getPlayerRunTime(result.getInt("ch.onlinetime"));
  1246. + String adenas = getAdenas(result.getInt("SUM(it.count)"));
  1247. +
  1248. + addChar(pos, result.getString("ch.char_name"), result.getInt("base_class"), result.getInt("ch.pvpkills"), result.getInt("ch.pkkills"), result.getInt("SUM(chr.points)"), adenas, timeon, status);
  1249. + }
  1250. +
  1251. + result.close();
  1252. + statement.close();
  1253. + }
  1254. + catch (Exception e)
  1255. + {
  1256. + e.printStackTrace();
  1257. + }
  1258. + finally
  1259. + {
  1260. + try
  1261. + {
  1262. + con.close();
  1263. + }
  1264. + catch (Exception e)
  1265. + {
  1266. +
  1267. + }
  1268. + }
  1269. + }
  1270. +
  1271. + public String loadTopList()
  1272. + {
  1273. + return _topList.toString();
  1274. + }
  1275. +
  1276. + private void addChar(int position, String name, int classid, int pvp, int pk, int raid, String adenas, String online, boolean isOnline)
  1277. + {
  1278. + _topList.append("<table border=0 cellspacing=0 cellpadding=2 bgcolor=050505 height=" + Config.TOP_PLAYER_ROW_HEIGHT + "><tr><td FIXWIDTH=5></td>");
  1279. + _topList.append("<td FIXWIDTH=20>" + position + ".</td>");
  1280. + _topList.append("<td FIXWIDTH=180>" + name + "</td>");
  1281. + _topList.append("<td FIXWIDTH=175>" + className(classid) + "</td>");
  1282. + _topList.append("<td FIXWIDTH=60>" + pvp + "</td>");
  1283. + _topList.append("<td FIXWIDTH=60>" + pk + "</td>");
  1284. + _topList.append("<td FIXWIDTH=65>" + raid + "</td>");
  1285. + _topList.append("<td FIXWIDTH=150>" + adenas + "</td>");
  1286. + _topList.append("<td FIXWIDTH=148>" + online + "</td>");
  1287. + _topList.append("<td FIXWIDTH=65>" + ((isOnline) ? "<font color=99FF00>Online</font>" : "<font color=CC0000>Offline</font>") + "</td>");
  1288. + _topList.append("</tr></table><img src=\"L2UI.Squaregray\" width=\"758\" height=\"1\">");
  1289. +
  1290. + }
  1291. +
  1292. + public final static String className(int classid)
  1293. + {
  1294. + Map<Integer, String> classList;
  1295. + classList = new FastMap<Integer, String>();
  1296. + classList.put(0, "Fighter");
  1297. + classList.put(1, "Warrior");
  1298. + classList.put(2, "Gladiator");
  1299. + classList.put(3, "Warlord");
  1300. + classList.put(4, "Knight");
  1301. + classList.put(5, "Paladin");
  1302. + classList.put(6, "Dark Avenger");
  1303. + classList.put(7, "Rogue");
  1304. + classList.put(8, "Treasure Hunter");
  1305. + classList.put(9, "Hawkeye");
  1306. + classList.put(10, "Mage");
  1307. + classList.put(11, "Wizard");
  1308. + classList.put(12, "Sorcerer");
  1309. + classList.put(13, "Necromancer");
  1310. + classList.put(14, "Warlock");
  1311. + classList.put(15, "Cleric");
  1312. + classList.put(16, "Bishop");
  1313. + classList.put(17, "Prophet");
  1314. + classList.put(18, "Elven Fighter");
  1315. + classList.put(19, "Elven Knight");
  1316. + classList.put(20, "Temple Knight");
  1317. + classList.put(21, "Swordsinger");
  1318. + classList.put(22, "Elven Scout");
  1319. + classList.put(23, "Plains Walker");
  1320. + classList.put(24, "Silver Ranger");
  1321. + classList.put(25, "Elven Mage");
  1322. + classList.put(26, "Elven Wizard");
  1323. + classList.put(27, "Spellsinger");
  1324. + classList.put(28, "Elemental Summoner");
  1325. + classList.put(29, "Oracle");
  1326. + classList.put(30, "Elder");
  1327. + classList.put(31, "Dark Fighter");
  1328. + classList.put(32, "Palus Knightr");
  1329. + classList.put(33, "Shillien Knight");
  1330. + classList.put(34, "Bladedancer");
  1331. + classList.put(35, "Assasin");
  1332. + classList.put(36, "Abyss Walker");
  1333. + classList.put(37, "Phantom Ranger");
  1334. + classList.put(38, "Dark Mage");
  1335. + classList.put(39, "Dark Wizard");
  1336. + classList.put(40, "Spellhowler");
  1337. + classList.put(41, "Phantom Summoner");
  1338. + classList.put(42, "Shillien Oracle");
  1339. + classList.put(43, "Shilien Elder");
  1340. + classList.put(44, "Orc Fighter");
  1341. + classList.put(45, "Orc Raider");
  1342. + classList.put(46, "Destroyer");
  1343. + classList.put(47, "Orc Monk");
  1344. + classList.put(48, "Tyrant");
  1345. + classList.put(49, "Orc Mage");
  1346. + classList.put(50, "Orc Shaman");
  1347. + classList.put(51, "Overlord");
  1348. + classList.put(52, "Warcryer");
  1349. + classList.put(53, "Dwarven Fighter");
  1350. + classList.put(54, "Scavenger");
  1351. + classList.put(55, "Bounty Hunter");
  1352. + classList.put(56, "Artisan");
  1353. + classList.put(57, "Warsmith");
  1354. + classList.put(88, "Duelist");
  1355. + classList.put(89, "Dreadnought");
  1356. + classList.put(90, "Phoenix Knight");
  1357. + classList.put(91, "Hell Knight");
  1358. + classList.put(92, "Sagittarius");
  1359. + classList.put(93, "Adventurer");
  1360. + classList.put(94, "Archmage");
  1361. + classList.put(95, "Soultaker");
  1362. + classList.put(96, "Arcana Lord");
  1363. + classList.put(97, "Cardinal");
  1364. + classList.put(98, "Hierophant");
  1365. + classList.put(99, "Evas Templar");
  1366. + classList.put(100, "Sword Muse");
  1367. + classList.put(101, "Wind Rider");
  1368. + classList.put(102, "Moonlight Sentinel");
  1369. + classList.put(103, "Mystic Muse");
  1370. + classList.put(104, "Elemental Master");
  1371. + classList.put(105, "Evas Saint");
  1372. + classList.put(106, "Shillien Templar");
  1373. + classList.put(107, "Spectral Dancer");
  1374. + classList.put(108, "Ghost Hunter");
  1375. + classList.put(109, "Ghost Sentinel");
  1376. + classList.put(110, "Storm Screamer");
  1377. + classList.put(111, "Spectral Master");
  1378. + classList.put(112, "Shillien Saint");
  1379. + classList.put(113, "Titan");
  1380. + classList.put(114, "Grand Khavatari");
  1381. + classList.put(115, "Dominator");
  1382. + classList.put(116, "Doomcryer");
  1383. + classList.put(117, "Fortune Seeker");
  1384. + classList.put(118, "Maestro");
  1385. + classList.put(123, "Male Soldier");
  1386. + classList.put(124, "Female Soldier");
  1387. + classList.put(125, "Trooper");
  1388. + classList.put(126, "Warder");
  1389. + classList.put(127, "Berserker");
  1390. + classList.put(128, "Male Soulbreaker");
  1391. + classList.put(129, "Female Soulbreaker");
  1392. + classList.put(130, "Arbalester");
  1393. + classList.put(131, "Doombringer");
  1394. + classList.put(132, "Male Soulhound");
  1395. + classList.put(133, "Female Soulhound");
  1396. + classList.put(134, "Trickster");
  1397. + classList.put(135, "Inspector");
  1398. + classList.put(136, "Judicator");
  1399. +
  1400. + return classList.get(classid);
  1401. + }
  1402. +
  1403. + public String getPlayerRunTime(int secs)
  1404. + {
  1405. + String timeResult = "";
  1406. + if (secs >= 86400)
  1407. + timeResult = Integer.toString(secs / 86400) + " Days " + Integer.toString((secs % 86400) / 3600) + " hours";
  1408. + else
  1409. + timeResult = Integer.toString(secs / 3600) + " Hours " + Integer.toString((secs % 3600) / 60) + " mins";
  1410. + return timeResult;
  1411. + }
  1412. + public String getAdenas(int adena)
  1413. + {
  1414. + String adenas = "";
  1415. + if (adena >= 1000000000)
  1416. + adenas = Integer.toString(adena / 1000000000) + " Billion " + Integer.toString((adena % 1000000000) / 1000000) + " million";
  1417. + else
  1418. + adenas = Integer.toString(adena / 1000000) + " Million " + Integer.toString((adena % 1000000) / 1000) + " k";
  1419. + return adenas;
  1420. + }
  1421. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement