CommunityBoard.java 4.9 KB

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