CommunityBoard.java 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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;
  16. import net.sf.l2j.Config;
  17. import net.sf.l2j.gameserver.communitybbs.Manager.ClanBBSManager;
  18. import net.sf.l2j.gameserver.communitybbs.Manager.PostBBSManager;
  19. import net.sf.l2j.gameserver.communitybbs.Manager.RegionBBSManager;
  20. import net.sf.l2j.gameserver.communitybbs.Manager.TopBBSManager;
  21. import net.sf.l2j.gameserver.communitybbs.Manager.TopicBBSManager;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  23. import net.sf.l2j.gameserver.network.L2GameClient;
  24. import net.sf.l2j.gameserver.network.SystemMessageId;
  25. import net.sf.l2j.gameserver.network.serverpackets.ShowBoard;
  26. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  27. public class CommunityBoard
  28. {
  29. private static CommunityBoard _instance;
  30. public CommunityBoard()
  31. {
  32. }
  33. public static CommunityBoard getInstance()
  34. {
  35. if (_instance == null)
  36. {
  37. _instance = new CommunityBoard();
  38. }
  39. return _instance;
  40. }
  41. public void handleCommands(L2GameClient client, String command)
  42. {
  43. L2PcInstance activeChar = client.getActiveChar();
  44. if (activeChar == null)
  45. return;
  46. if (Config.COMMUNITY_TYPE.equals("full"))
  47. {
  48. if (command.startsWith("_bbsclan"))
  49. {
  50. ClanBBSManager.getInstance().parsecmd(command, activeChar);
  51. }
  52. else if (command.startsWith("_bbsmemo"))
  53. {
  54. TopicBBSManager.getInstance().parsecmd(command, activeChar);
  55. }
  56. else if (command.startsWith("_bbstopics"))
  57. {
  58. TopicBBSManager.getInstance().parsecmd(command, activeChar);
  59. }
  60. else if (command.startsWith("_bbsposts"))
  61. {
  62. PostBBSManager.getInstance().parsecmd(command, activeChar);
  63. }
  64. else if (command.startsWith("_bbstop"))
  65. {
  66. TopBBSManager.getInstance().parsecmd(command, activeChar);
  67. }
  68. else if (command.startsWith("_bbshome"))
  69. {
  70. TopBBSManager.getInstance().parsecmd(command, activeChar);
  71. }
  72. else if (command.startsWith("_bbsloc"))
  73. {
  74. RegionBBSManager.getInstance().parsecmd(command, activeChar);
  75. }
  76. else
  77. {
  78. ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
  79. activeChar.sendPacket(sb);
  80. activeChar.sendPacket(new ShowBoard(null, "102"));
  81. activeChar.sendPacket(new ShowBoard(null, "103"));
  82. }
  83. }
  84. else if (Config.COMMUNITY_TYPE.equals("old"))
  85. {
  86. RegionBBSManager.getInstance().parsecmd(command, activeChar);
  87. }
  88. else
  89. {
  90. activeChar.sendPacket(new SystemMessage(SystemMessageId.CB_OFFLINE));
  91. }
  92. }
  93. /**
  94. * @param client
  95. * @param url
  96. * @param arg1
  97. * @param arg2
  98. * @param arg3
  99. * @param arg4
  100. * @param arg5
  101. */
  102. public void handleWriteCommands(L2GameClient client, String url, String arg1, String arg2, String arg3, String arg4, String arg5)
  103. {
  104. L2PcInstance activeChar = client.getActiveChar();
  105. if (activeChar == null)
  106. return;
  107. if (Config.COMMUNITY_TYPE.equals("full"))
  108. {
  109. if (url.equals("Topic"))
  110. {
  111. TopicBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  112. }
  113. else if (url.equals("Post"))
  114. {
  115. PostBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  116. }
  117. else if (url.equals("Region"))
  118. {
  119. RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  120. }
  121. else
  122. {
  123. ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + url + " is not implemented yet</center><br><br></body></html>", "101");
  124. activeChar.sendPacket(sb);
  125. activeChar.sendPacket(new ShowBoard(null, "102"));
  126. activeChar.sendPacket(new ShowBoard(null, "103"));
  127. }
  128. }
  129. else if (Config.COMMUNITY_TYPE.equals("old"))
  130. {
  131. RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  132. }
  133. else
  134. {
  135. ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disable</center><br><br></body></html>", "101");
  136. activeChar.sendPacket(sb);
  137. activeChar.sendPacket(new ShowBoard(null, "102"));
  138. activeChar.sendPacket(new ShowBoard(null, "103"));
  139. }
  140. }
  141. }