ClanBBSManager.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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.StringTokenizer;
  17. import javolution.text.TextBuilder;
  18. import net.sf.l2j.gameserver.datatables.ClanTable;
  19. import net.sf.l2j.gameserver.model.L2Clan;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  21. import net.sf.l2j.gameserver.network.SystemMessageId;
  22. import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  23. public class ClanBBSManager extends BaseBBSManager
  24. {
  25. private static ClanBBSManager _instance = new ClanBBSManager();
  26. /**
  27. * @return
  28. */
  29. public static ClanBBSManager getInstance()
  30. {
  31. return _instance;
  32. }
  33. /**
  34. * @param command
  35. * @param activeChar
  36. */
  37. @Override
  38. public void parsecmd(String command, L2PcInstance activeChar)
  39. {
  40. if (command.equals("_bbsclan"))
  41. {
  42. if (activeChar.getClan() != null)
  43. {
  44. if (activeChar.getClan().getLevel() >= 2)
  45. {
  46. clanhome(activeChar);
  47. }
  48. else
  49. {
  50. clanlist(activeChar, 1);
  51. }
  52. }
  53. else
  54. {
  55. clanlist(activeChar, 1);
  56. }
  57. }
  58. else if (command.startsWith("_bbsclan_clanlist"))
  59. {
  60. if (command.equals("_bbsclan_clanlist"))
  61. {
  62. clanlist(activeChar, 1);
  63. }
  64. else if (command.startsWith("_bbsclan_clanlist;"))
  65. {
  66. StringTokenizer st = new StringTokenizer(command, ";");
  67. st.nextToken();
  68. int index = Integer.parseInt(st.nextToken());
  69. clanlist(activeChar, index);
  70. }
  71. }
  72. else if (command.startsWith("_bbsclan_clanhome"))
  73. {
  74. if (command.equals("_bbsclan_clanhome"))
  75. {
  76. clanhome(activeChar);
  77. }
  78. else if (command.startsWith("_bbsclan_clanhome;"))
  79. {
  80. StringTokenizer st = new StringTokenizer(command, ";");
  81. st.nextToken();
  82. int index = Integer.parseInt(st.nextToken());
  83. clanhome(activeChar, index);
  84. }
  85. }
  86. else
  87. {
  88. separateAndSend("<html><body><br><br><center>Commande : " + command
  89. + " pas encore implante</center><br><br></body></html>", activeChar);
  90. }
  91. }
  92. /**
  93. * @param activeChar
  94. */
  95. private void clanlist(L2PcInstance activeChar, int index)
  96. {
  97. if (index < 1)
  98. {
  99. index = 1;
  100. }
  101. //header
  102. TextBuilder html = new TextBuilder("<html><body><br><br><center>");
  103. html.append("<br1><br1><table border=0 cellspacing=0 cellpadding=0>");
  104. html.append("<tr><td FIXWIDTH=15>&nbsp;</td>");
  105. html.append("<td width=610 height=30 align=left>");
  106. html.append("<a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a>");
  107. html.append("</td></tr></table>");
  108. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>");
  109. html.append("<tr><td height=10></td></tr>");
  110. html.append("<tr>");
  111. html.append("<td fixWIDTH=5></td>");
  112. html.append("<td fixWIDTH=600>");
  113. html.append("<a action=\"bypass _bbsclan_clanhome;"
  114. + ((activeChar.getClan() != null) ? activeChar.getClan().getClanId() : 0)
  115. + "\">[GO TO MY CLAN]</a>&nbsp;&nbsp;");
  116. html.append("</td>");
  117. html.append("<td fixWIDTH=5></td>");
  118. html.append("</tr>");
  119. html.append("<tr><td height=10></td></tr>");
  120. html.append("</table>");
  121. //body
  122. html.append("<br>");
  123. html.append("<table border=0 cellspacing=0 cellpadding=2 bgcolor=5A5A5A width=610>");
  124. html.append("<tr>");
  125. html.append("<td FIXWIDTH=5></td>");
  126. html.append("<td FIXWIDTH=200 align=center>CLAN NAME</td>");
  127. html.append("<td FIXWIDTH=200 align=center>CLAN LEADER</td>");
  128. html.append("<td FIXWIDTH=100 align=center>CLAN LEVEL</td>");
  129. html.append("<td FIXWIDTH=100 align=center>CLAN MEMBERS</td>");
  130. html.append("<td FIXWIDTH=5></td>");
  131. html.append("</tr>");
  132. html.append("</table>");
  133. html.append("<img src=\"L2UI.Squareblank\" width=\"1\" height=\"5\">");
  134. int i = 0;
  135. for (L2Clan cl : ClanTable.getInstance().getClans())
  136. {
  137. if(i > (index + 1)*7)
  138. {
  139. break;
  140. }
  141. if(i >= (index - 1)*7)
  142. {
  143. html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">");
  144. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610>");
  145. html.append("<tr> ");
  146. html.append("<td FIXWIDTH=5></td>");
  147. html.append("<td FIXWIDTH=200 align=center><a action=\"bypass _bbsclan_clanhome;"
  148. + cl.getClanId() + "\">" + cl.getName() + "</a></td>");
  149. html.append("<td FIXWIDTH=200 align=center>" + cl.getLeaderName() + "</td>");
  150. html.append("<td FIXWIDTH=100 align=center>" + cl.getLevel() + "</td>");
  151. html.append("<td FIXWIDTH=100 align=center>" + cl.getMembersCount() + "</td>");
  152. html.append("<td FIXWIDTH=5></td>");
  153. html.append("</tr>");
  154. html.append("<tr><td height=5></td></tr>");
  155. html.append("</table>");
  156. html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">");
  157. html.append("<img src=\"L2UI.SquareGray\" width=\"610\" height=\"1\">");
  158. }
  159. i++;
  160. }
  161. html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"2\">");
  162. html.append("<table cellpadding=0 cellspacing=2 border=0><tr>");
  163. if (index == 1)
  164. {
  165. html.append("<td><button action=\"\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
  166. }
  167. else
  168. {
  169. html.append("<td><button action=\"_bbsclan_clanlist;" + (index - 1)
  170. + "\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
  171. }
  172. i = 0;
  173. int nbp;
  174. nbp = ClanTable.getInstance().getClans().length / 8;
  175. if (nbp * 8 != ClanTable.getInstance().getClans().length)
  176. {
  177. nbp++;
  178. }
  179. for (i = 1; i <= nbp; i++)
  180. {
  181. if (i == index)
  182. {
  183. html.append("<td> " + i + " </td>");
  184. }
  185. else
  186. {
  187. html.append("<td><a action=\"bypass _bbsclan_clanlist;" + i + "\"> " + i + " </a></td>");
  188. }
  189. }
  190. if (index == nbp)
  191. {
  192. html.append("<td><button action=\"\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
  193. }
  194. else
  195. {
  196. html.append("<td><button action=\"bypass _bbsclan_clanlist;" + (index + 1)
  197. + "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
  198. }
  199. html.append("</tr></table>");
  200. html.append("<table border=0 cellspacing=0 cellpadding=0>");
  201. html.append("<tr><td width=610><img src=\"sek.cbui141\" width=\"610\" height=\"1\"></td></tr>");
  202. html.append("</table>");
  203. html.append("<table border=0><tr><td><combobox width=65 var=keyword list=\"Name;Ruler\"></td><td><edit var = \"Search\" width=130 height=11 length=\"16\"></td>");
  204. //TODO: search (Write in BBS)
  205. html.append("<td><button value=\"&$420;\" action=\"Write 5 -1 0 Search keyword keyword\" back=\"l2ui_ch3.smallbutton2_down\" width=65 height=20 fore=\"l2ui_ch3.smallbutton2\"> </td> </tr></table>");
  206. html.append("<br>");
  207. html.append("<br>");
  208. html.append("</center>");
  209. html.append("</body>");
  210. html.append("</html>");
  211. separateAndSend(html.toString(), activeChar);
  212. }
  213. /**
  214. * @param activeChar
  215. */
  216. private void clanhome(L2PcInstance activeChar)
  217. {
  218. clanhome(activeChar, activeChar.getClan().getClanId());
  219. }
  220. /**
  221. * @param activeChar
  222. * @param clanId
  223. */
  224. private void clanhome(L2PcInstance activeChar, int clanId)
  225. {
  226. L2Clan cl = ClanTable.getInstance().getClan(clanId);
  227. if (cl != null)
  228. {
  229. if (cl.getLevel() < 2)
  230. {
  231. activeChar.sendPacket(new SystemMessage(SystemMessageId.NO_CB_IN_MY_CLAN));
  232. parsecmd("_bbsclan_clanlist",activeChar);
  233. }
  234. else
  235. {
  236. TextBuilder html = new TextBuilder("<html><body><center><br><br>");
  237. html.append("<br1><br1><table border=0 cellspacing=0 cellpadding=0>");
  238. html.append("<tr><td FIXWIDTH=15>&nbsp;</td>");
  239. html.append("<td width=610 height=30 align=left>");
  240. html.append("<a action=\"bypass _bbshome\">HOME</a> &gt; <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> &gt; <a action=\"bypass _bbsclan_clanhome;"
  241. + clanId + "\"> &amp;$802; </a>");
  242. html.append("</td></tr></table>");
  243. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>");
  244. html.append("<tr><td height=10></td></tr>");
  245. html.append("<tr>");
  246. html.append("<td fixWIDTH=5></td>");
  247. html.append("<td fixwidth=600>");
  248. html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId
  249. + ";announce\">[CLAN ANNOUNCEMENT]</a> <a action=\"bypass _bbsclan_clanhome;"
  250. + clanId + ";cbb\">[CLAN BULLETIN BOARD]</a>");
  251. html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId
  252. + ";cmail\">[CLAN MAIL]</a>&nbsp;&nbsp;");
  253. html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId
  254. + ";cnotice\">[CLAN NOTICE]</a>&nbsp;&nbsp;");
  255. html.append("</td>");
  256. html.append("<td fixWIDTH=5></td>");
  257. html.append("</tr>");
  258. html.append("<tr><td height=10></td></tr>");
  259. html.append("</table>");
  260. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610>");
  261. html.append("<tr><td height=10></td></tr>");
  262. html.append("<tr><td fixWIDTH=5></td>");
  263. html.append("<td fixwidth=290 valign=top>");
  264. html.append("</td>");
  265. html.append("<td fixWIDTH=5></td>");
  266. html.append("<td fixWIDTH=5 align=center valign=top><img src=\"l2ui.squaregray\" width=2 height=128></td>");
  267. html.append("<td fixWIDTH=5></td>");
  268. html.append("<td fixwidth=295>");
  269. html.append("<table border=0 cellspacing=0 cellpadding=0 width=295>");
  270. html.append("<tr>");
  271. html.append("<td fixWIDTH=100 align=left>CLAN NAME</td>");
  272. html.append("<td fixWIDTH=195 align=left>" + cl.getName() + "</td>");
  273. html.append("</tr>");
  274. html.append("<tr><td height=7></td></tr>");
  275. html.append("<tr>");
  276. html.append("<td fixWIDTH=100 align=left>CLAN LEVEL</td>");
  277. html.append("<td fixWIDTH=195 align=left height=16>" + cl.getLevel() + "</td>");
  278. html.append("</tr>");
  279. html.append("<tr><td height=7></td></tr>");
  280. html.append("<tr>");
  281. html.append("<td fixWIDTH=100 align=left>CLAN MEMBERS</td>");
  282. html.append("<td fixWIDTH=195 align=left height=16>" + cl.getMembersCount() + "</td>");
  283. html.append("</tr>");
  284. html.append("<tr><td height=7></td></tr>");
  285. html.append("<tr>");
  286. html.append("<td fixWIDTH=100 align=left>CLAN LEADER</td>");
  287. html.append("<td fixWIDTH=195 align=left height=16>" + cl.getLeaderName() + "</td>");
  288. html.append("</tr>");
  289. html.append("<tr><td height=7></td></tr>");
  290. //ADMINISTRATOR ??
  291. /*html.append("<tr>");
  292. html.append("<td fixWIDTH=100 align=left>ADMINISTRATOR</td>");
  293. html.append("<td fixWIDTH=195 align=left height=16>"+cl.getLeaderName()+"</td>");
  294. html.append("</tr>");*/
  295. html.append("<tr><td height=7></td></tr>");
  296. html.append("<tr>");
  297. html.append("<td fixWIDTH=100 align=left>ALLIANCE</td>");
  298. html.append("<td fixWIDTH=195 align=left height=16>"
  299. + ((cl.getAllyName() != null) ? cl.getAllyName() : "") + "</td>");
  300. html.append("</tr>");
  301. html.append("</table>");
  302. html.append("</td>");
  303. html.append("<td fixWIDTH=5></td>");
  304. html.append("</tr>");
  305. html.append("<tr><td height=10></td></tr>");
  306. html.append("</table>");
  307. //TODO: the BB for clan :)
  308. //html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=333333>");
  309. html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">");
  310. html.append("<img src=\"L2UI.squaregray\" width=\"610\" height=\"1\">");
  311. html.append("<br>");
  312. html.append("</center>");
  313. html.append("<br> <br>");
  314. html.append("</body>");
  315. html.append("</html>");
  316. separateAndSend(html.toString(), activeChar);
  317. }
  318. }
  319. }
  320. /* (non-Javadoc)
  321. * @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)
  322. */
  323. @Override
  324. public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
  325. {
  326. // TODO Auto-generated method stub
  327. }
  328. }