Advertisement
LIONN

[L2jFrozen] Admin Chat Manager

Jan 30th, 2013
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 9.11 KB | None | 0 0
  1. Index: sql/admin_command_access_rights.sql
  2. ===================================================================
  3. --- sql/admin_command_access_rights.sql (revision 984)
  4. +++ sql/admin_command_access_rights.sql (working copy)
  5. @@ -77,6 +77,9 @@
  6.  -- Section: ChangeLevel
  7.  ('admin_changelvl','2'),
  8.  
  9. +-- Section: ChatManager
  10. +('admin_quiet','1'),
  11. +
  12.  -- Section: Christmas
  13.  ('admin_christmas_start','3'),
  14.  ('admin_christmas_end','3'),
  15. Index: head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminChatManager.java
  16. ===================================================================
  17. --- head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminChatManager.java    (revision 0)
  18. +++ head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminChatManager.java    (working copy)
  19. @@ -0,0 +1,107 @@
  20. +/*
  21. + * This program is free software: you can redistribute it and/or modify it under
  22. + * the terms of the GNU General Public License as published by the Free Software
  23. + * Foundation, either version 3 of the License, or (at your option) any later
  24. + * version.
  25. + *
  26. + * This program is distributed in the hope that it will be useful, but WITHOUT
  27. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  28. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  29. + * details.
  30. + *
  31. + * You should have received a copy of the GNU General Public License along with
  32. + * this program. If not, see <http://www.gnu.org/licenses/>.
  33. + */
  34. +package com.l2jfrozen.gameserver.handler.admincommandhandlers;
  35. +
  36. +import java.util.StringTokenizer;
  37. +
  38. +import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
  39. +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  40. +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
  41. +
  42. +public class AdminChatManager implements IAdminCommandHandler
  43. +{
  44. +   private static final String[] ADMIN_COMMANDS =
  45. +   {
  46. +       "admin_quiet"
  47. +   };
  48. +
  49. +   @Override
  50. +   public boolean useAdminCommand(String command, L2PcInstance activeChar)
  51. +   {
  52. +       if (command.startsWith("admin_quiet"))
  53. +       {
  54. +           StringTokenizer st = new StringTokenizer(command);
  55. +           st.nextToken();
  56. +
  57. +           try
  58. +           {
  59. +               String type = st.nextToken();
  60. +               if (type.startsWith("all"))
  61. +               {
  62. +                   if (!Say2.isChatDisabled("all"))
  63. +                   {
  64. +                       Say2.setIsChatDisabled("all", true);
  65. +                       activeChar.sendMessage("All chats have been disabled!   ");
  66. +                   }
  67. +                   else
  68. +                   {
  69. +                       Say2.setIsChatDisabled("all", false);
  70. +                       activeChar.sendMessage("All Chats have been enabled!");
  71. +                   }
  72. +               }
  73. +               else if (type.startsWith("hero"))
  74. +               {
  75. +                   if (!Say2.isChatDisabled("hero"))
  76. +                   {
  77. +                       Say2.setIsChatDisabled("hero", true);
  78. +                       activeChar.sendMessage("Hero Voice has been disabled!");
  79. +                   }
  80. +                   else
  81. +                   {
  82. +                       Say2.setIsChatDisabled("hero", false);
  83. +                       activeChar.sendMessage("Hero Voice has been enabled!");
  84. +                   }
  85. +               }
  86. +               else if (type.startsWith("trade"))
  87. +               {
  88. +                   if (!Say2.isChatDisabled("trade"))
  89. +                   {
  90. +                       Say2.setIsChatDisabled("trade", true);
  91. +                       activeChar.sendMessage("Trade Chat has been disabled!");
  92. +                   }
  93. +                   else
  94. +                   {
  95. +                       Say2.setIsChatDisabled("trade", false);
  96. +                       activeChar.sendMessage("Trade Chat has been enabled!");
  97. +                   }
  98. +               }
  99. +               else if (type.startsWith("global"))
  100. +               {
  101. +                   if (!Say2.isChatDisabled("global"))
  102. +                   {
  103. +                       Say2.setIsChatDisabled("global", true);
  104. +                       activeChar.sendMessage("Global Chat has been disabled!");
  105. +                   }
  106. +                   else
  107. +                   {
  108. +                       Say2.setIsChatDisabled("global", false);
  109. +                       activeChar.sendMessage("Global Chat has been enabled!");
  110. +                   }
  111. +               }
  112. +           }
  113. +           catch (Exception e)
  114. +           {
  115. +               activeChar.sendMessage("Usage : //quiet <all|hero|trade|global>");
  116. +           }
  117. +       }
  118. +       return true;
  119. +   }
  120. +
  121. +   @Override
  122. +   public String[] getAdminCommandList()
  123. +   {
  124. +       return ADMIN_COMMANDS;
  125. +   }
  126. +}
  127. Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
  128. ===================================================================
  129. --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java   (revision 984)
  130. +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java   (working copy)
  131. @@ -83,6 +83,11 @@
  132.     private SystemChatChannelId _type2Check;
  133.     private String _target;
  134.  
  135. +   private static boolean _chatDisabled = false;
  136. +   private static boolean _globalChatDisabled = false;
  137. +   private static boolean _tradeChatDisabled = false;
  138. +   private static boolean _heroChatDisabled = false;
  139. +  
  140.     @Override
  141.     protected void readImpl()
  142.     {
  143. @@ -138,6 +143,12 @@
  144.             return;
  145.         }
  146.        
  147. +       if (isChatDisabled("all") && !activeChar.isGM())
  148. +       {
  149. +           activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
  150. +           return;
  151. +       }
  152. +      
  153.         if( activeChar.isChatBanned() && !activeChar.isGM() && _type != CLAN && _type != ALLIANCE && _type != PARTY)
  154.         {
  155.             activeChar.sendMessage("You may not chat while a chat ban is in effect.");
  156. @@ -346,6 +357,12 @@
  157.                 if (!getClient().getFloodProtectors().getGlobalChat().tryPerformAction("global chat"))
  158.                     return;
  159.  
  160. +               if (isChatDisabled("global") && !activeChar.isGM())
  161. +               {
  162. +                   activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
  163. +                   return;
  164. +               }
  165. +              
  166.                    if(Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") || Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.isGM())
  167.                    {
  168.                       int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
  169. @@ -387,6 +404,12 @@
  170.                    }
  171.                    break;
  172.                 case TRADE:
  173. +                   if (isChatDisabled("trade") && !activeChar.isGM())
  174. +                   {
  175. +                       activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
  176. +                       return;
  177. +                   }
  178. +                  
  179.                    if(Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("ON"))
  180.                    {
  181.                       if(Config.TRADE_CHAT_WITH_PVP)
  182. @@ -543,6 +566,12 @@
  183.                 }
  184.                 break;
  185.             case HERO_VOICE:
  186. +               if (isChatDisabled("hero") && !activeChar.isGM())
  187. +               {
  188. +                   activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
  189. +                   return;
  190. +               }
  191. +              
  192.                 if(activeChar.isGM())
  193.                 {
  194.                     for(L2PcInstance player : L2World.getInstance().getAllPlayers()){
  195. @@ -623,6 +652,34 @@
  196.         }
  197.     }
  198.  
  199. +   public static boolean isChatDisabled(String chatType)
  200. +   {
  201. +       boolean chatDisabled = false;
  202. +
  203. +       if(chatType.equalsIgnoreCase("all"))
  204. +           chatDisabled = _chatDisabled;
  205. +       else if(chatType.equalsIgnoreCase("hero"))
  206. +           chatDisabled = _heroChatDisabled;
  207. +       else if(chatType.equalsIgnoreCase("trade"))
  208. +           chatDisabled = _tradeChatDisabled;
  209. +       else if(chatType.equalsIgnoreCase("global"))
  210. +           chatDisabled = _globalChatDisabled;
  211. +
  212. +       return chatDisabled;
  213. +   }
  214. +
  215. +   public static void setIsChatDisabled(String chatType, boolean chatDisabled)
  216. +   {
  217. +       if(chatType.equalsIgnoreCase("all"))
  218. +           _chatDisabled = chatDisabled;
  219. +       else if(chatType.equalsIgnoreCase("hero"))
  220. +           _heroChatDisabled = chatDisabled;
  221. +       else if(chatType.equalsIgnoreCase("trade"))
  222. +           _tradeChatDisabled = chatDisabled;
  223. +       else if(chatType.equalsIgnoreCase("global"))
  224. +           _globalChatDisabled = chatDisabled;
  225. +   }
  226. +
  227.     @Override
  228.     public String getType()
  229.     {
  230. Index: head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java
  231. ===================================================================
  232. --- head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java  (revision 984)
  233. +++ head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java  (working copy)
  234. @@ -36,6 +36,7 @@
  235.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCache;
  236.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminChangeAccessLevel;
  237.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCharSupervision;
  238. +import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminChatManager;
  239.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminChristmas;
  240.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCreateItem;
  241.  import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
  242. @@ -185,6 +186,7 @@
  243.         registerAdminCommandHandler(new AdminBuffs());
  244.         registerAdminCommandHandler(new AdminAio());
  245.         registerAdminCommandHandler(new AdminCharSupervision());
  246. +       registerAdminCommandHandler(new AdminChatManager());
  247.         registerAdminCommandHandler(new AdminWho()); // L2OFF command
  248.         // ATTENTION: adding new command handlers, you have to change the
  249.         // sql file containing the access levels rights
  250. Index: head-src/com/l2jfrozen/gameserver/network/SystemMessageId.java
  251. ===================================================================
  252. --- head-src/com/l2jfrozen/gameserver/network/SystemMessageId.java  (revision 984)
  253. +++ head-src/com/l2jfrozen/gameserver/network/SystemMessageId.java  (working copy)
  254. @@ -2114,6 +2114,12 @@
  255.     CANNOT_GIVE_ITEMS_TO_DEAD_PET(590),
  256.  
  257.     /**
  258. +    * ID: 599<br>
  259. +    * Message: The GM has an important notice. Chat has been temporarily disabled.
  260. +    */
  261. +   GM_NOTICE_CHAT_DISABLED(599),
  262. +  
  263. +   /**
  264.      * ID: 600<br>
  265.      * Message: You may not equip a pet item.
  266.      */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement