CommunityBoard.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (C) 2004-2013 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.communitybbs;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.communitybbs.Manager.ClanBBSManager;
  22. import com.l2jserver.gameserver.communitybbs.Manager.PostBBSManager;
  23. import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
  24. import com.l2jserver.gameserver.communitybbs.Manager.TopBBSManager;
  25. import com.l2jserver.gameserver.communitybbs.Manager.TopicBBSManager;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  27. import com.l2jserver.gameserver.network.L2GameClient;
  28. import com.l2jserver.gameserver.network.SystemMessageId;
  29. import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
  30. public class CommunityBoard
  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. {
  41. return;
  42. }
  43. switch (Config.COMMUNITY_TYPE)
  44. {
  45. default:
  46. case 0: // disabled
  47. activeChar.sendPacket(SystemMessageId.CB_OFFLINE);
  48. break;
  49. case 1: // old
  50. RegionBBSManager.getInstance().parsecmd(command, activeChar);
  51. break;
  52. case 2: // new
  53. if (command.startsWith("_bbsclan"))
  54. {
  55. ClanBBSManager.getInstance().parsecmd(command, activeChar);
  56. }
  57. else if (command.startsWith("_bbsmemo"))
  58. {
  59. TopicBBSManager.getInstance().parsecmd(command, activeChar);
  60. }
  61. else if (command.startsWith("_bbstopics"))
  62. {
  63. TopicBBSManager.getInstance().parsecmd(command, activeChar);
  64. }
  65. else if (command.startsWith("_bbsposts"))
  66. {
  67. PostBBSManager.getInstance().parsecmd(command, activeChar);
  68. }
  69. else if (command.startsWith("_bbstop"))
  70. {
  71. TopBBSManager.getInstance().parsecmd(command, activeChar);
  72. }
  73. else if (command.startsWith("_bbshome"))
  74. {
  75. TopBBSManager.getInstance().parsecmd(command, activeChar);
  76. }
  77. else if (command.startsWith("_bbsloc"))
  78. {
  79. RegionBBSManager.getInstance().parsecmd(command, activeChar);
  80. }
  81. else
  82. {
  83. ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + command + " is not implemented yet</center><br><br></body></html>", "101");
  84. activeChar.sendPacket(sb);
  85. activeChar.sendPacket(new ShowBoard(null, "102"));
  86. activeChar.sendPacket(new ShowBoard(null, "103"));
  87. }
  88. break;
  89. }
  90. }
  91. /**
  92. * @param client
  93. * @param url
  94. * @param arg1
  95. * @param arg2
  96. * @param arg3
  97. * @param arg4
  98. * @param arg5
  99. */
  100. public void handleWriteCommands(L2GameClient client, String url, String arg1, String arg2, String arg3, String arg4, String arg5)
  101. {
  102. L2PcInstance activeChar = client.getActiveChar();
  103. if (activeChar == null)
  104. {
  105. return;
  106. }
  107. switch (Config.COMMUNITY_TYPE)
  108. {
  109. case 2:
  110. if (url.equals("Topic"))
  111. {
  112. TopicBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  113. }
  114. else if (url.equals("Post"))
  115. {
  116. PostBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  117. }
  118. else if (url.equals("Region"))
  119. {
  120. RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  121. }
  122. else if (url.equals("Notice"))
  123. {
  124. ClanBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  125. }
  126. else
  127. {
  128. ShowBoard sb = new ShowBoard("<html><body><br><br><center>the command: " + url + " is not implemented yet</center><br><br></body></html>", "101");
  129. activeChar.sendPacket(sb);
  130. activeChar.sendPacket(new ShowBoard(null, "102"));
  131. activeChar.sendPacket(new ShowBoard(null, "103"));
  132. }
  133. break;
  134. case 1:
  135. RegionBBSManager.getInstance().parsewrite(arg1, arg2, arg3, arg4, arg5, activeChar);
  136. break;
  137. default:
  138. case 0:
  139. ShowBoard sb = new ShowBoard("<html><body><br><br><center>The Community board is currently disabled</center><br><br></body></html>", "101");
  140. activeChar.sendPacket(sb);
  141. activeChar.sendPacket(new ShowBoard(null, "102"));
  142. activeChar.sendPacket(new ShowBoard(null, "103"));
  143. break;
  144. }
  145. }
  146. private static class SingletonHolder
  147. {
  148. protected static final CommunityBoard _instance = new CommunityBoard();
  149. }
  150. }