CommunityBoard.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. private CommunityBoard()
  29. {
  30. }
  31. public static CommunityBoard getInstance()
  32. {
  33. return SingletonHolder._instance;
  34. }
  35. public void handleCommands(L2GameClient client, String command)
  36. {
  37. L2PcInstance activeChar = client.getActiveChar();
  38. if (activeChar == null)
  39. return;
  40. switch (Config.COMMUNITY_TYPE)
  41. {
  42. default:
  43. case 0: //disabled
  44. activeChar.sendPacket(SystemMessageId.CB_OFFLINE);
  45. break;
  46. case 1: // old
  47. RegionBBSManager.getInstance().parsecmd(command, activeChar);
  48. break;
  49. case 2: // new
  50. if (command.startsWith("_bbsclan"))
  51. {
  52. ClanBBSManager.getInstance().parsecmd(command, activeChar);
  53. }
  54. else if (command.startsWith("_bbsmemo"))
  55. {
  56. TopicBBSManager.getInstance().parsecmd(command, activeChar);
  57. }
  58. else if (command.startsWith("_bbstopics"))
  59. {
  60. TopicBBSManager.getInstance().parsecmd(command, activeChar);
  61. }
  62. else if (command.startsWith("_bbsposts"))
  63. {
  64. PostBBSManager.getInstance().parsecmd(command, activeChar);
  65. }
  66. else if (command.startsWith("_bbstop"))
  67. {
  68. TopBBSManager.getInstance().parsecmd(command, activeChar);
  69. }
  70. else if (command.startsWith("_bbshome"))
  71. {
  72. TopBBSManager.getInstance().parsecmd(command, activeChar);
  73. }
  74. else if (command.startsWith("_bbsloc"))
  75. {
  76. RegionBBSManager.getInstance().parsecmd(command, activeChar);
  77. }
  78. else
  79. {
  80. ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command
  81. + " 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. break;
  87. }
  88. }
  89. /**
  90. * @param client
  91. * @param url
  92. * @param arg1
  93. * @param arg2
  94. * @param arg3
  95. * @param arg4
  96. * @param arg5
  97. */
  98. public void handleWriteCommands(L2GameClient client, String url, String arg1, String arg2, String arg3, String arg4, String arg5)
  99. {
  100. L2PcInstance activeChar = client.getActiveChar();
  101. if (activeChar == null)
  102. return;
  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
  125. + " is not implemented yet</center><br><br></body></html>", "101");
  126. activeChar.sendPacket(sb);
  127. activeChar.sendPacket(new ShowBoard(null, "102"));
  128. activeChar.sendPacket(new ShowBoard(null, "103"));
  129. }
  130. break;
  131. case 1:
  132. RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  133. break;
  134. default:
  135. case 0:
  136. ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disabled</center><br><br></body></html>", "101");
  137. activeChar.sendPacket(sb);
  138. activeChar.sendPacket(new ShowBoard(null, "102"));
  139. activeChar.sendPacket(new ShowBoard(null, "103"));
  140. break;
  141. }
  142. }
  143. @SuppressWarnings("synthetic-access")
  144. private static class SingletonHolder
  145. {
  146. protected static final CommunityBoard _instance = new CommunityBoard();
  147. }
  148. }