RegionBBSManager.java 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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.communitybbs.Manager;
  16. import java.util.Collections;
  17. import java.util.Comparator;
  18. import java.util.StringTokenizer;
  19. import java.util.logging.Level;
  20. import java.util.logging.LogRecord;
  21. import java.util.logging.Logger;
  22. import javolution.text.TextBuilder;
  23. import javolution.util.FastList;
  24. import javolution.util.FastMap;
  25. import net.sf.l2j.Config;
  26. import net.sf.l2j.gameserver.GameServer;
  27. import net.sf.l2j.gameserver.model.BlockList;
  28. import net.sf.l2j.gameserver.model.L2World;
  29. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  30. import net.sf.l2j.gameserver.model.base.Experience;
  31. import net.sf.l2j.gameserver.network.SystemMessageId;
  32. import net.sf.l2j.gameserver.network.clientpackets.Say2;
  33. import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  34. import net.sf.l2j.gameserver.network.serverpackets.ShowBoard;
  35. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  36. public class RegionBBSManager extends BaseBBSManager
  37. {
  38. private static Logger _logChat = Logger.getLogger("chat");
  39. /**
  40. *
  41. * @see net.sf.l2j.gameserver.communitybbs.Manager.BaseBBSManager#parsecmd(java.lang.String, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance)
  42. */
  43. @Override
  44. public void parsecmd(String command, L2PcInstance activeChar)
  45. {
  46. if (command.equals("_bbsloc"))
  47. {
  48. showOldCommunity(activeChar, 1);
  49. }
  50. else if (command.startsWith("_bbsloc;page;"))
  51. {
  52. StringTokenizer st = new StringTokenizer(command, ";");
  53. st.nextToken();
  54. st.nextToken();
  55. int page = 0;
  56. try
  57. {
  58. page = Integer.parseInt(st.nextToken());
  59. }
  60. catch (NumberFormatException nfe)
  61. {
  62. }
  63. showOldCommunity(activeChar, page);
  64. }
  65. else if (command.startsWith("_bbsloc;playerinfo;"))
  66. {
  67. StringTokenizer st = new StringTokenizer(command, ";");
  68. st.nextToken();
  69. st.nextToken();
  70. String name = st.nextToken();
  71. showOldCommunityPI(activeChar, name);
  72. }
  73. else
  74. {
  75. if (Config.COMMUNITY_TYPE == 1)
  76. {
  77. showOldCommunity(activeChar, 1);
  78. }
  79. else
  80. {
  81. ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
  82. activeChar.sendPacket(sb);
  83. activeChar.sendPacket(new ShowBoard(null, "102"));
  84. activeChar.sendPacket(new ShowBoard(null, "103"));
  85. }
  86. }
  87. }
  88. /**
  89. * @param activeChar
  90. * @param name
  91. */
  92. private void showOldCommunityPI(L2PcInstance activeChar, String name)
  93. {
  94. TextBuilder htmlCode = new TextBuilder("<html><body><br>");
  95. htmlCode.append("<table border=0><tr><td FIXWIDTH=15></td><td align=center>L2J Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>");
  96. L2PcInstance player = L2World.getInstance().getPlayer(name);
  97. if (player != null)
  98. {
  99. String sex = "Male";
  100. if (player.getAppearance().getSex())
  101. {
  102. sex = "Female";
  103. }
  104. String levelApprox = "low";
  105. if (player.getLevel() >= 60)
  106. levelApprox = "very high";
  107. else if (player.getLevel() >= 40)
  108. levelApprox = "high";
  109. else if (player.getLevel() >= 20)
  110. levelApprox = "medium";
  111. htmlCode.append("<table border=0><tr><td>" + player.getName() + " (" + sex + " " + player.getTemplate().className + "):</td></tr>");
  112. htmlCode.append("<tr><td>Level: " + levelApprox + "</td></tr>");
  113. htmlCode.append("<tr><td><br></td></tr>");
  114. if (activeChar != null && (activeChar.isGM() || player.getObjectId() == activeChar.getObjectId() || Config.SHOW_LEVEL_COMMUNITYBOARD))
  115. {
  116. long nextLevelExp = 0;
  117. long nextLevelExpNeeded = 0;
  118. if (player.getLevel() < (Experience.MAX_LEVEL - 1))
  119. {
  120. nextLevelExp = Experience.LEVEL[player.getLevel() + 1];
  121. nextLevelExpNeeded = nextLevelExp - player.getExp();
  122. }
  123. htmlCode.append("<tr><td>Level: " + player.getLevel() + "</td></tr>");
  124. htmlCode.append("<tr><td>Experience: " + player.getExp() + "/" + nextLevelExp + "</td></tr>");
  125. htmlCode.append("<tr><td>Experience needed for level up: " + nextLevelExpNeeded + "</td></tr>");
  126. htmlCode.append("<tr><td><br></td></tr>");
  127. }
  128. int uptime = (int) player.getUptime() / 1000;
  129. int h = uptime / 3600;
  130. int m = (uptime - (h * 3600)) / 60;
  131. int s = ((uptime - (h * 3600)) - (m * 60));
  132. htmlCode.append("<tr><td>Uptime: " + h + "h " + m + "m " + s + "s</td></tr>");
  133. htmlCode.append("<tr><td><br></td></tr>");
  134. if (player.getClan() != null)
  135. {
  136. htmlCode.append("<tr><td>Clan: " + player.getClan().getName() + "</td></tr>");
  137. htmlCode.append("<tr><td><br></td></tr>");
  138. }
  139. htmlCode.append("<tr><td><multiedit var=\"pm\" width=240 height=40><button value=\"Send PM\" action=\"Write Region PM "
  140. + player.getName()
  141. + " pm pm pm\" width=110 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><br><button value=\"Back\" action=\"bypass _bbsloc\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>");
  142. htmlCode.append("</td></tr></table>");
  143. htmlCode.append("</body></html>");
  144. separateAndSend(htmlCode.toString(), activeChar);
  145. }
  146. else
  147. {
  148. ShowBoard sb = new ShowBoard("<html><body><br><br><center>No player with name " + name + "</center><br><br></body></html>", "101");
  149. activeChar.sendPacket(sb);
  150. activeChar.sendPacket(new ShowBoard(null, "102"));
  151. activeChar.sendPacket(new ShowBoard(null, "103"));
  152. }
  153. }
  154. /**
  155. * @param activeChar
  156. */
  157. private void showOldCommunity(L2PcInstance activeChar, int page)
  158. {
  159. separateAndSend(getCommunityPage(page, activeChar.isGM() ? "gm" : "pl"), activeChar);
  160. }
  161. /* (non-Javadoc)
  162. * @see net.sf.l2j.gameserver.communitybbs.Manager.BaseBBSManager#parsewrite(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance)
  163. */
  164. @Override
  165. public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
  166. {
  167. if (activeChar == null)
  168. return;
  169. if (ar1.equals("PM"))
  170. {
  171. TextBuilder htmlCode = new TextBuilder("<html><body><br>");
  172. htmlCode.append("<table border=0><tr><td FIXWIDTH=15></td><td align=center>L2J Community Board<img src=\"sek.cbui355\" width=610 height=1></td></tr><tr><td FIXWIDTH=15></td><td>");
  173. try
  174. {
  175. L2PcInstance receiver = L2World.getInstance().getPlayer(ar2);
  176. if (receiver == null)
  177. {
  178. htmlCode.append("Player not found!<br><button value=\"Back\" action=\"bypass _bbsloc;playerinfo;" + ar2 + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  179. htmlCode.append("</td></tr></table></body></html>");
  180. separateAndSend(htmlCode.toString(), activeChar);
  181. return;
  182. }
  183. if (Config.JAIL_DISABLE_CHAT && receiver.isInJail())
  184. {
  185. activeChar.sendMessage("Player is in jail.");
  186. return;
  187. }
  188. if (receiver.isChatBanned())
  189. {
  190. activeChar.sendMessage("Player is chat banned.");
  191. return;
  192. }
  193. if (activeChar.isInJail() && Config.JAIL_DISABLE_CHAT)
  194. {
  195. activeChar.sendMessage("You can not chat while in jail.");
  196. return;
  197. }
  198. if (Config.LOG_CHAT)
  199. {
  200. LogRecord record = new LogRecord(Level.INFO, ar3);
  201. record.setLoggerName("chat");
  202. record.setParameters(new Object[]
  203. {
  204. "TELL", "[" + activeChar.getName() + " to " + receiver.getName() + "]"
  205. });
  206. _logChat.log(record);
  207. }
  208. CreatureSay cs = new CreatureSay(activeChar.getObjectId(), Say2.TELL, activeChar.getName(), ar3);
  209. if (receiver != null && !BlockList.isBlocked(receiver, activeChar))
  210. {
  211. if (!receiver.getMessageRefusal())
  212. {
  213. receiver.sendPacket(cs);
  214. activeChar.sendPacket(new CreatureSay(activeChar.getObjectId(), Say2.TELL, "->" + receiver.getName(), ar3));
  215. htmlCode.append("Message Sent<br><button value=\"Back\" action=\"bypass _bbsloc;playerinfo;" + receiver.getName() + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
  216. htmlCode.append("</td></tr></table></body></html>");
  217. separateAndSend(htmlCode.toString(), activeChar);
  218. }
  219. else
  220. {
  221. SystemMessage sm = new SystemMessage(SystemMessageId.THE_PERSON_IS_IN_MESSAGE_REFUSAL_MODE);
  222. activeChar.sendPacket(sm);
  223. parsecmd("_bbsloc;playerinfo;" + receiver.getName(), activeChar);
  224. }
  225. }
  226. else
  227. {
  228. SystemMessage sm = new SystemMessage(SystemMessageId.S1_IS_NOT_ONLINE);
  229. sm.addString(receiver.getName());
  230. activeChar.sendPacket(sm);
  231. sm = null;
  232. }
  233. }
  234. catch (StringIndexOutOfBoundsException e)
  235. {
  236. // ignore
  237. }
  238. }
  239. else
  240. {
  241. ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + ar1 + " is not implemented yet</center><br><br></body></html>", "101");
  242. activeChar.sendPacket(sb);
  243. activeChar.sendPacket(new ShowBoard(null, "102"));
  244. activeChar.sendPacket(new ShowBoard(null, "103"));
  245. }
  246. }
  247. private static RegionBBSManager _instance = null;
  248. private int _onlineCount = 0;
  249. private int _onlineCountGm = 0;
  250. private static FastMap<Integer, FastList<L2PcInstance>> _onlinePlayers = new FastMap<Integer, FastList<L2PcInstance>>().setShared(true);
  251. private static FastMap<Integer, FastMap<String, String>> _communityPages = new FastMap<Integer, FastMap<String, String>>().setShared(true);
  252. /**
  253. * @return
  254. */
  255. public static RegionBBSManager getInstance()
  256. {
  257. if (_instance == null)
  258. {
  259. _instance = new RegionBBSManager();
  260. }
  261. return _instance;
  262. }
  263. public synchronized void changeCommunityBoard()
  264. {
  265. FastList<L2PcInstance> sortedPlayers = new FastList<L2PcInstance>();
  266. //synchronized (L2World.getInstance().getAllPlayers())
  267. {
  268. sortedPlayers.addAll(L2World.getInstance().getAllPlayers().values());
  269. }
  270. Collections.sort(sortedPlayers, new Comparator<L2PcInstance>() {
  271. public int compare(L2PcInstance p1, L2PcInstance p2)
  272. {
  273. return p1.getName().compareToIgnoreCase(p2.getName());
  274. }
  275. });
  276. _onlinePlayers.clear();
  277. _onlineCount = 0;
  278. _onlineCountGm = 0;
  279. for (L2PcInstance player : sortedPlayers)
  280. {
  281. addOnlinePlayer(player);
  282. }
  283. _communityPages.clear();
  284. writeCommunityPages();
  285. }
  286. private void addOnlinePlayer(L2PcInstance player)
  287. {
  288. boolean added = false;
  289. for (FastList<L2PcInstance> page : _onlinePlayers.values())
  290. {
  291. if (page.size() < Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
  292. {
  293. if (!page.contains(player))
  294. {
  295. page.add(player);
  296. if (!player.getAppearance().getInvisible())
  297. _onlineCount++;
  298. _onlineCountGm++;
  299. }
  300. added = true;
  301. break;
  302. }
  303. else if (page.contains(player))
  304. {
  305. added = true;
  306. break;
  307. }
  308. }
  309. if (!added)
  310. {
  311. FastList<L2PcInstance> temp = new FastList<L2PcInstance>();
  312. int page = _onlinePlayers.size() + 1;
  313. if (temp.add(player))
  314. {
  315. _onlinePlayers.put(page, temp);
  316. if (!player.getAppearance().getInvisible())
  317. _onlineCount++;
  318. _onlineCountGm++;
  319. }
  320. }
  321. }
  322. private void writeCommunityPages()
  323. {
  324. for (int page : _onlinePlayers.keySet())
  325. {
  326. FastMap<String, String> communityPage = new FastMap<String, String>();
  327. TextBuilder htmlCode = new TextBuilder("<html><body><br>");
  328. String tdClose = "</td>";
  329. String tdOpen = "<td align=left valign=top>";
  330. String trClose = "</tr>";
  331. String trOpen = "<tr>";
  332. String colSpacer = "<td FIXWIDTH=15></td>";
  333. htmlCode.append("<table>");
  334. htmlCode.append(trOpen);
  335. htmlCode.append("<td align=left valign=top>Server Restarted: " + GameServer.dateTimeServerStarted.getTime() + tdClose);
  336. htmlCode.append(trClose);
  337. htmlCode.append("</table>");
  338. htmlCode.append("<table>");
  339. htmlCode.append(trOpen);
  340. htmlCode.append(tdOpen + "XP Rate: x" + Config.RATE_XP + tdClose);
  341. htmlCode.append(colSpacer);
  342. htmlCode.append(tdOpen + "Party XP Rate: x" + Config.RATE_XP * Config.RATE_PARTY_XP + tdClose);
  343. htmlCode.append(colSpacer);
  344. htmlCode.append(tdOpen + "XP Exponent: " + Config.ALT_GAME_EXPONENT_XP + tdClose);
  345. htmlCode.append(trClose);
  346. htmlCode.append(trOpen);
  347. htmlCode.append(tdOpen + "SP Rate: x" + Config.RATE_SP + tdClose);
  348. htmlCode.append(colSpacer);
  349. htmlCode.append(tdOpen + "Party SP Rate: x" + Config.RATE_SP * Config.RATE_PARTY_SP + tdClose);
  350. htmlCode.append(colSpacer);
  351. htmlCode.append(tdOpen + "SP Exponent: " + Config.ALT_GAME_EXPONENT_SP + tdClose);
  352. htmlCode.append(trClose);
  353. htmlCode.append(trOpen);
  354. htmlCode.append(tdOpen + "Drop Rate: " + Config.RATE_DROP_ITEMS + tdClose);
  355. htmlCode.append(colSpacer);
  356. htmlCode.append(tdOpen + "Spoil Rate: " + Config.RATE_DROP_SPOIL + tdClose);
  357. htmlCode.append(colSpacer);
  358. htmlCode.append(tdOpen + "Adena Rate: " + Config.RATE_DROP_ADENA + tdClose);
  359. htmlCode.append(trClose);
  360. htmlCode.append("</table>");
  361. htmlCode.append("<table>");
  362. htmlCode.append(trOpen);
  363. htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
  364. htmlCode.append(trClose);
  365. htmlCode.append(trOpen);
  366. htmlCode.append(tdOpen + L2World.getInstance().getAllVisibleObjectsCount() + " Object count</td>");
  367. htmlCode.append(trClose);
  368. htmlCode.append(trOpen);
  369. htmlCode.append(tdOpen + getOnlineCount("gm") + " Player(s) Online</td>");
  370. htmlCode.append(trClose);
  371. htmlCode.append("</table>");
  372. int cell = 0;
  373. if (Config.BBS_SHOW_PLAYERLIST)
  374. {
  375. htmlCode.append("<table border=0>");
  376. htmlCode.append("<tr><td><table border=0>");
  377. for (L2PcInstance player : getOnlinePlayers(page))
  378. {
  379. cell++;
  380. if (cell == 1)
  381. htmlCode.append(trOpen);
  382. htmlCode.append("<td align=left valign=top FIXWIDTH=110><a action=\"bypass _bbsloc;playerinfo;" + player.getName() + "\">");
  383. if (player.isGM())
  384. htmlCode.append("<font color=\"LEVEL\">" + player.getName() + "</font>");
  385. else
  386. htmlCode.append(player.getName());
  387. htmlCode.append("</a></td>");
  388. if (cell < Config.NAME_PER_ROW_COMMUNITYBOARD)
  389. htmlCode.append(colSpacer);
  390. if (cell == Config.NAME_PER_ROW_COMMUNITYBOARD)
  391. {
  392. cell = 0;
  393. htmlCode.append(trClose);
  394. }
  395. }
  396. if (cell > 0 && cell < Config.NAME_PER_ROW_COMMUNITYBOARD)
  397. htmlCode.append(trClose);
  398. htmlCode.append("</table><br></td></tr>");
  399. htmlCode.append(trOpen);
  400. htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
  401. htmlCode.append(trClose);
  402. htmlCode.append("</table>");
  403. }
  404. if (getOnlineCount("gm") > Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
  405. {
  406. htmlCode.append("<table border=0 width=600>");
  407. htmlCode.append("<tr>");
  408. if (page == 1)
  409. htmlCode.append("<td align=right width=190><button value=\"Prev\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  410. else
  411. htmlCode.append("<td align=right width=190><button value=\"Prev\" action=\"bypass _bbsloc;page;" + (page - 1) + "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  412. htmlCode.append("<td FIXWIDTH=10></td>");
  413. htmlCode.append("<td align=center valign=top width=200>Displaying " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + 1) + " - " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + getOnlinePlayers(page).size())
  414. + " player(s)</td>");
  415. htmlCode.append("<td FIXWIDTH=10></td>");
  416. if (getOnlineCount("gm") <= (page * Config.NAME_PAGE_SIZE_COMMUNITYBOARD))
  417. htmlCode.append("<td width=190><button value=\"Next\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  418. else
  419. htmlCode.append("<td width=190><button value=\"Next\" action=\"bypass _bbsloc;page;" + (page + 1) + "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  420. htmlCode.append("</tr>");
  421. htmlCode.append("</table>");
  422. }
  423. htmlCode.append("</body></html>");
  424. communityPage.put("gm", htmlCode.toString());
  425. htmlCode = new TextBuilder("<html><body><br>");
  426. htmlCode.append("<table>");
  427. htmlCode.append(trOpen);
  428. htmlCode.append("<td align=left valign=top>Server Restarted: " + GameServer.dateTimeServerStarted.getTime() + tdClose);
  429. htmlCode.append(trClose);
  430. htmlCode.append("</table>");
  431. htmlCode.append("<table>");
  432. htmlCode.append(trOpen);
  433. htmlCode.append(tdOpen + "XP Rate: " + Config.RATE_XP + tdClose);
  434. htmlCode.append(colSpacer);
  435. htmlCode.append(tdOpen + "Party XP Rate: " + Config.RATE_PARTY_XP + tdClose);
  436. htmlCode.append(colSpacer);
  437. htmlCode.append(tdOpen + "XP Exponent: " + Config.ALT_GAME_EXPONENT_XP + tdClose);
  438. htmlCode.append(trClose);
  439. htmlCode.append(trOpen);
  440. htmlCode.append(tdOpen + "SP Rate: " + Config.RATE_SP + tdClose);
  441. htmlCode.append(colSpacer);
  442. htmlCode.append(tdOpen + "Party SP Rate: " + Config.RATE_PARTY_SP + tdClose);
  443. htmlCode.append(colSpacer);
  444. htmlCode.append(tdOpen + "SP Exponent: " + Config.ALT_GAME_EXPONENT_SP + tdClose);
  445. htmlCode.append(trClose);
  446. htmlCode.append(trOpen);
  447. htmlCode.append(tdOpen + "Drop Rate: " + Config.RATE_DROP_ITEMS + tdClose);
  448. htmlCode.append(colSpacer);
  449. htmlCode.append(tdOpen + "Spoil Rate: " + Config.RATE_DROP_SPOIL + tdClose);
  450. htmlCode.append(colSpacer);
  451. htmlCode.append(tdOpen + "Adena Rate: " + Config.RATE_DROP_ADENA + tdClose);
  452. htmlCode.append(trClose);
  453. htmlCode.append("</table>");
  454. htmlCode.append("<table>");
  455. htmlCode.append(trOpen);
  456. htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
  457. htmlCode.append(trClose);
  458. htmlCode.append(trOpen);
  459. htmlCode.append(tdOpen + getOnlineCount("pl") + " Player(s) Online</td>");
  460. htmlCode.append(trClose);
  461. htmlCode.append("</table>");
  462. if (Config.BBS_SHOW_PLAYERLIST)
  463. {
  464. htmlCode.append("<table border=0>");
  465. htmlCode.append("<tr><td><table border=0>");
  466. cell = 0;
  467. for (L2PcInstance player : getOnlinePlayers(page))
  468. {
  469. if ((player == null) || (player.getAppearance().getInvisible()))
  470. continue; // Go to next
  471. cell++;
  472. if (cell == 1)
  473. htmlCode.append(trOpen);
  474. htmlCode.append("<td align=left valign=top FIXWIDTH=110><a action=\"bypass _bbsloc;playerinfo;" + player.getName() + "\">");
  475. if (player.isGM())
  476. htmlCode.append("<font color=\"LEVEL\">" + player.getName() + "</font>");
  477. else
  478. htmlCode.append(player.getName());
  479. htmlCode.append("</a></td>");
  480. if (cell < Config.NAME_PER_ROW_COMMUNITYBOARD)
  481. htmlCode.append(colSpacer);
  482. if (cell == Config.NAME_PER_ROW_COMMUNITYBOARD)
  483. {
  484. cell = 0;
  485. htmlCode.append(trClose);
  486. }
  487. }
  488. if (cell > 0 && cell < Config.NAME_PER_ROW_COMMUNITYBOARD)
  489. htmlCode.append(trClose);
  490. htmlCode.append("</table><br></td></tr>");
  491. htmlCode.append(trOpen);
  492. htmlCode.append("<td><img src=\"sek.cbui355\" width=600 height=1><br></td>");
  493. htmlCode.append(trClose);
  494. htmlCode.append("</table>");
  495. }
  496. if (getOnlineCount("pl") > Config.NAME_PAGE_SIZE_COMMUNITYBOARD)
  497. {
  498. htmlCode.append("<table border=0 width=600>");
  499. htmlCode.append("<tr>");
  500. if (page == 1)
  501. htmlCode.append("<td align=right width=190><button value=\"Prev\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  502. else
  503. htmlCode.append("<td align=right width=190><button value=\"Prev\" action=\"bypass _bbsloc;page;" + (page - 1) + "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  504. htmlCode.append("<td FIXWIDTH=10></td>");
  505. htmlCode.append("<td align=center valign=top width=200>Displaying " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + 1) + " - " + (((page - 1) * Config.NAME_PAGE_SIZE_COMMUNITYBOARD) + getOnlinePlayers(page).size())
  506. + " player(s)</td>");
  507. htmlCode.append("<td FIXWIDTH=10></td>");
  508. if (getOnlineCount("pl") <= (page * Config.NAME_PAGE_SIZE_COMMUNITYBOARD))
  509. htmlCode.append("<td width=190><button value=\"Next\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  510. else
  511. htmlCode.append("<td width=190><button value=\"Next\" action=\"bypass _bbsloc;page;" + (page + 1) + "\" width=50 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
  512. htmlCode.append("</tr>");
  513. htmlCode.append("</table>");
  514. }
  515. htmlCode.append("</body></html>");
  516. communityPage.put("pl", htmlCode.toString());
  517. _communityPages.put(page, communityPage);
  518. }
  519. }
  520. private int getOnlineCount(String type)
  521. {
  522. if (type.equalsIgnoreCase("gm"))
  523. return _onlineCountGm;
  524. else
  525. return _onlineCount;
  526. }
  527. private FastList<L2PcInstance> getOnlinePlayers(int page)
  528. {
  529. return _onlinePlayers.get(page);
  530. }
  531. public String getCommunityPage(int page, String type)
  532. {
  533. if (_communityPages.get(page) != null)
  534. return _communityPages.get(page).get(type);
  535. else
  536. return null;
  537. }
  538. }