ClanBBSManager.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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.network.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 + " pas encore implante</center><br><br></body></html>", activeChar);
  89. }
  90. }
  91. /**
  92. * @param activeChar
  93. */
  94. private void clanlist(L2PcInstance activeChar, int index)
  95. {
  96. if (index < 1)
  97. {
  98. index = 1;
  99. }
  100. //header
  101. TextBuilder html = new TextBuilder("<html><body><br><br><center>");
  102. html.append("<br1><br1><table border=0 cellspacing=0 cellpadding=0>");
  103. html.append("<tr><td FIXWIDTH=15>&nbsp;</td>");
  104. html.append("<td width=610 height=30 align=left>");
  105. html.append("<a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a>");
  106. html.append("</td></tr></table>");
  107. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>");
  108. html.append("<tr><td height=10></td></tr>");
  109. html.append("<tr>");
  110. html.append("<td fixWIDTH=5></td>");
  111. html.append("<td fixWIDTH=600>");
  112. html.append("<a action=\"bypass _bbsclan_clanhome;" + ((activeChar.getClan() != null) ? activeChar.getClan().getClanId() : 0) + "\">[GO TO MY CLAN]</a>&nbsp;&nbsp;");
  113. html.append("</td>");
  114. html.append("<td fixWIDTH=5></td>");
  115. html.append("</tr>");
  116. html.append("<tr><td height=10></td></tr>");
  117. html.append("</table>");
  118. //body
  119. html.append("<br>");
  120. html.append("<table border=0 cellspacing=0 cellpadding=2 bgcolor=5A5A5A width=610>");
  121. html.append("<tr>");
  122. html.append("<td FIXWIDTH=5></td>");
  123. html.append("<td FIXWIDTH=200 align=center>CLAN NAME</td>");
  124. html.append("<td FIXWIDTH=200 align=center>CLAN LEADER</td>");
  125. html.append("<td FIXWIDTH=100 align=center>CLAN LEVEL</td>");
  126. html.append("<td FIXWIDTH=100 align=center>CLAN MEMBERS</td>");
  127. html.append("<td FIXWIDTH=5></td>");
  128. html.append("</tr>");
  129. html.append("</table>");
  130. html.append("<img src=\"L2UI.Squareblank\" width=\"1\" height=\"5\">");
  131. int i = 0;
  132. for (L2Clan cl : ClanTable.getInstance().getClans())
  133. {
  134. if (i > (index + 1) * 7)
  135. {
  136. break;
  137. }
  138. if (i >= (index - 1) * 7)
  139. {
  140. html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">");
  141. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610>");
  142. html.append("<tr> ");
  143. html.append("<td FIXWIDTH=5></td>");
  144. html.append("<td FIXWIDTH=200 align=center><a action=\"bypass _bbsclan_clanhome;" + cl.getClanId() + "\">" + cl.getName() + "</a></td>");
  145. html.append("<td FIXWIDTH=200 align=center>" + cl.getLeaderName() + "</td>");
  146. html.append("<td FIXWIDTH=100 align=center>" + cl.getLevel() + "</td>");
  147. html.append("<td FIXWIDTH=100 align=center>" + cl.getMembersCount() + "</td>");
  148. html.append("<td FIXWIDTH=5></td>");
  149. html.append("</tr>");
  150. html.append("<tr><td height=5></td></tr>");
  151. html.append("</table>");
  152. html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"3\">");
  153. html.append("<img src=\"L2UI.SquareGray\" width=\"610\" height=\"1\">");
  154. }
  155. i++;
  156. }
  157. html.append("<img src=\"L2UI.SquareBlank\" width=\"610\" height=\"2\">");
  158. html.append("<table cellpadding=0 cellspacing=2 border=0><tr>");
  159. if (index == 1)
  160. {
  161. html.append("<td><button action=\"\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
  162. }
  163. else
  164. {
  165. html.append("<td><button action=\"_bbsclan_clanlist;" + (index - 1) + "\" back=\"l2ui_ch3.prev1_down\" fore=\"l2ui_ch3.prev1\" width=16 height=16 ></td>");
  166. }
  167. i = 0;
  168. int nbp;
  169. nbp = ClanTable.getInstance().getClans().length / 8;
  170. if (nbp * 8 != ClanTable.getInstance().getClans().length)
  171. {
  172. nbp++;
  173. }
  174. for (i = 1; i <= nbp; i++)
  175. {
  176. if (i == index)
  177. {
  178. html.append("<td> " + i + " </td>");
  179. }
  180. else
  181. {
  182. html.append("<td><a action=\"bypass _bbsclan_clanlist;" + i + "\"> " + i + " </a></td>");
  183. }
  184. }
  185. if (index == nbp)
  186. {
  187. html.append("<td><button action=\"\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
  188. }
  189. else
  190. {
  191. html.append("<td><button action=\"bypass _bbsclan_clanlist;" + (index + 1) + "\" back=\"l2ui_ch3.next1_down\" fore=\"l2ui_ch3.next1\" width=16 height=16 ></td>");
  192. }
  193. html.append("</tr></table>");
  194. html.append("<table border=0 cellspacing=0 cellpadding=0>");
  195. html.append("<tr><td width=610><img src=\"sek.cbui141\" width=\"610\" height=\"1\"></td></tr>");
  196. html.append("</table>");
  197. 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>");
  198. //TODO: search (Write in BBS)
  199. 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>");
  200. html.append("<br>");
  201. html.append("<br>");
  202. html.append("</center>");
  203. html.append("</body>");
  204. html.append("</html>");
  205. separateAndSend(html.toString(), activeChar);
  206. }
  207. /**
  208. * @param activeChar
  209. */
  210. private void clanhome(L2PcInstance activeChar)
  211. {
  212. clanhome(activeChar, activeChar.getClan().getClanId());
  213. }
  214. /**
  215. * @param activeChar
  216. * @param clanId
  217. */
  218. private void clanhome(L2PcInstance activeChar, int clanId)
  219. {
  220. L2Clan cl = ClanTable.getInstance().getClan(clanId);
  221. if (cl != null)
  222. {
  223. if (cl.getLevel() < 2)
  224. {
  225. activeChar.sendPacket(new SystemMessage(SystemMessageId.NO_CB_IN_MY_CLAN));
  226. parsecmd("_bbsclan_clanlist", activeChar);
  227. }
  228. else
  229. {
  230. TextBuilder html = new TextBuilder("<html><body><center><br><br>");
  231. html.append("<br1><br1><table border=0 cellspacing=0 cellpadding=0>");
  232. html.append("<tr><td FIXWIDTH=15>&nbsp;</td>");
  233. html.append("<td width=610 height=30 align=left>");
  234. html.append("<a action=\"bypass _bbshome\">HOME</a> &gt; <a action=\"bypass _bbsclan_clanlist\"> CLAN COMMUNITY </a> &gt; <a action=\"bypass _bbsclan_clanhome;" + clanId + "\"> &amp;$802; </a>");
  235. html.append("</td></tr></table>");
  236. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=434343>");
  237. html.append("<tr><td height=10></td></tr>");
  238. html.append("<tr>");
  239. html.append("<td fixWIDTH=5></td>");
  240. html.append("<td fixwidth=600>");
  241. html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";announce\">[CLAN ANNOUNCEMENT]</a> <a action=\"bypass _bbsclan_clanhome;" + clanId + ";cbb\">[CLAN BULLETIN BOARD]</a>");
  242. html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";cmail\">[CLAN MAIL]</a>&nbsp;&nbsp;");
  243. html.append("<a action=\"bypass _bbsclan_clanhome;" + clanId + ";cnotice\">[CLAN NOTICE]</a>&nbsp;&nbsp;");
  244. html.append("</td>");
  245. html.append("<td fixWIDTH=5></td>");
  246. html.append("</tr>");
  247. html.append("<tr><td height=10></td></tr>");
  248. html.append("</table>");
  249. html.append("<table border=0 cellspacing=0 cellpadding=0 width=610>");
  250. html.append("<tr><td height=10></td></tr>");
  251. html.append("<tr><td fixWIDTH=5></td>");
  252. html.append("<td fixwidth=290 valign=top>");
  253. html.append("</td>");
  254. html.append("<td fixWIDTH=5></td>");
  255. html.append("<td fixWIDTH=5 align=center valign=top><img src=\"l2ui.squaregray\" width=2 height=128></td>");
  256. html.append("<td fixWIDTH=5></td>");
  257. html.append("<td fixwidth=295>");
  258. html.append("<table border=0 cellspacing=0 cellpadding=0 width=295>");
  259. html.append("<tr>");
  260. html.append("<td fixWIDTH=100 align=left>CLAN NAME</td>");
  261. html.append("<td fixWIDTH=195 align=left>" + cl.getName() + "</td>");
  262. html.append("</tr>");
  263. html.append("<tr><td height=7></td></tr>");
  264. html.append("<tr>");
  265. html.append("<td fixWIDTH=100 align=left>CLAN LEVEL</td>");
  266. html.append("<td fixWIDTH=195 align=left height=16>" + cl.getLevel() + "</td>");
  267. html.append("</tr>");
  268. html.append("<tr><td height=7></td></tr>");
  269. html.append("<tr>");
  270. html.append("<td fixWIDTH=100 align=left>CLAN MEMBERS</td>");
  271. html.append("<td fixWIDTH=195 align=left height=16>" + cl.getMembersCount() + "</td>");
  272. html.append("</tr>");
  273. html.append("<tr><td height=7></td></tr>");
  274. html.append("<tr>");
  275. html.append("<td fixWIDTH=100 align=left>CLAN LEADER</td>");
  276. html.append("<td fixWIDTH=195 align=left height=16>" + cl.getLeaderName() + "</td>");
  277. html.append("</tr>");
  278. html.append("<tr><td height=7></td></tr>");
  279. //ADMINISTRATOR ??
  280. /*html.append("<tr>");
  281. html.append("<td fixWIDTH=100 align=left>ADMINISTRATOR</td>");
  282. html.append("<td fixWIDTH=195 align=left height=16>"+cl.getLeaderName()+"</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>ALLIANCE</td>");
  287. html.append("<td fixWIDTH=195 align=left height=16>" + ((cl.getAllyName() != null) ? cl.getAllyName() : "") + "</td>");
  288. html.append("</tr>");
  289. html.append("</table>");
  290. html.append("</td>");
  291. html.append("<td fixWIDTH=5></td>");
  292. html.append("</tr>");
  293. html.append("<tr><td height=10></td></tr>");
  294. html.append("</table>");
  295. //TODO: the BB for clan :)
  296. //html.append("<table border=0 cellspacing=0 cellpadding=0 width=610 bgcolor=333333>");
  297. html.append("<img src=\"L2UI.squareblank\" width=\"1\" height=\"5\">");
  298. html.append("<img src=\"L2UI.squaregray\" width=\"610\" height=\"1\">");
  299. html.append("<br>");
  300. html.append("</center>");
  301. html.append("<br> <br>");
  302. html.append("</body>");
  303. html.append("</html>");
  304. separateAndSend(html.toString(), activeChar);
  305. }
  306. }
  307. }
  308. /* (non-Javadoc)
  309. * @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)
  310. */
  311. @Override
  312. public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
  313. {
  314. // TODO Auto-generated method stub
  315. }
  316. }