CommunityBoard.java 5.1 KB

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