CommunityBoard.java 4.9 KB

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