Advertisement
LIONN

[aCis] Admin Chat Manager

Jan 29th, 2013
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 12.00 KB | None | 0 0
  1. Index: data/xml/admin_commands_rights.xml
  2. ===================================================================
  3. --- data/xml/admin_commands_rights.xml  (revision 10)
  4. +++ data/xml/admin_commands_rights.xml  (working copy)
  5. @@ -54,6 +54,9 @@
  6.     <!-- CHANGE ACCESS LEVEL -->
  7.     <aCar name="admin_changelvl" accessLevel="1" />
  8.  
  9. +   <!-- CHAT MANAGER -->
  10. +   <aCar name="admin_quiet" accessLevel="1" />
  11. +
  12.     <!-- CREATE ITEM -->
  13.     <aCar name="admin_itemcreate" accessLevel="1" />
  14.     <aCar name="admin_create_item" accessLevel="1" />
  15. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java
  16. ===================================================================
  17. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java  (revision 10)
  18. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java  (working copy)
  19. @@ -21,6 +21,7 @@
  20.  import net.sf.l2j.gameserver.model.BlockList;
  21.  import net.sf.l2j.gameserver.model.L2World;
  22.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  23. +import net.sf.l2j.gameserver.network.SystemMessageId;
  24.  import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  25.  
  26.  /**
  27. @@ -32,12 +33,20 @@
  28.  {
  29.     private static final int[] COMMAND_IDS = { 1 };
  30.  
  31. +   private static boolean _chatDisabled = false;
  32. +
  33.     /**
  34.      * Handle chat type 'shout'
  35.      * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  36.      */
  37.     public void handleChat(int type, L2PcInstance activeChar, String target, String text)
  38.     {
  39. +       if (isChatDisabled() && !activeChar.isGM())
  40. +       {
  41. +           activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
  42. +           return;
  43. +       }
  44. +
  45.         CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  46.         Collection<L2PcInstance> pls = null;
  47.         switch (activeChar.getFactionId()) {
  48. @@ -68,6 +77,22 @@
  49.     }
  50.  
  51.     /**
  52. +    * @return Returns the chatDisabled.
  53. +    */
  54. +   public static boolean isChatDisabled()
  55. +   {
  56. +       return _chatDisabled;
  57. +   }
  58. +
  59. +   /**
  60. +    * @param chatDisabled The chatDisabled to set.
  61. +    */
  62. +   public static void setIsChatDisabled(boolean chatDisabled)
  63. +   {
  64. +       _chatDisabled = chatDisabled;
  65. +   }
  66. +
  67. +   /**
  68.      * Returns the chat types registered to this handler
  69.      * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
  70.      */
  71. Index: java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
  72. ===================================================================
  73. --- java/net/sf/l2j/gameserver/network/clientpackets/Say2.java  (revision 10)
  74. +++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java  (working copy)
  75. @@ -81,6 +81,8 @@
  76.     private int _type;
  77.     private String _target;
  78.    
  79. +   private static boolean _chatDisabled = false;
  80. +  
  81.     @Override
  82.     protected void readImpl()
  83.     {
  84. @@ -99,6 +101,12 @@
  85.         if (activeChar == null)
  86.             return;
  87.        
  88. +       if (isChatDisabled() && !activeChar.isGM())
  89. +       {
  90. +           activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
  91. +           return;
  92. +       }
  93. +      
  94.         if (_type < 0 || _type >= CHAT_NAMES.length)
  95.         {
  96.             _log.warning("Say2: Invalid type: " +_type + " Player : " + activeChar.getName() + " text: " + String.valueOf(_text));
  97. @@ -172,6 +180,22 @@
  98.         return false;
  99.     }
  100.    
  101. +   /**
  102. +    * @return Returns the chatDisabled.
  103. +    */
  104. +   public static boolean isChatDisabled()
  105. +   {
  106. +       return _chatDisabled;
  107. +   }
  108. +
  109. +   /**
  110. +    * @param chatDisabled The chatDisabled to set.
  111. +    */
  112. +   public static void setIsChatDisabled(boolean chatDisabled)
  113. +   {
  114. +       _chatDisabled = chatDisabled;
  115. +   }
  116. +
  117.     @Override
  118.     protected boolean triggersOnActionRequest()
  119.     {
  120. Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
  121. ===================================================================
  122. --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 10)
  123. +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
  124. @@ -26,6 +26,7 @@
  125.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCache;
  126.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCamera;
  127.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminChangeAccessLevel;
  128. +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminChatManager;
  129.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCreateItem;
  130.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
  131.  import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminDelete;
  132. @@ -88,6 +89,7 @@
  133.          registerAdminCommandHandler(new AdminCache());
  134.          registerAdminCommandHandler(new AdminCamera());
  135.          registerAdminCommandHandler(new AdminChangeAccessLevel());
  136. +        registerAdminCommandHandler(new AdminChatManager());
  137.          registerAdminCommandHandler(new AdminCreateItem());
  138.          registerAdminCommandHandler(new AdminCursedWeapons());
  139.          registerAdminCommandHandler(new AdminDelete());
  140. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChatManager.java
  141. ===================================================================
  142. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChatManager.java   (revision 0)
  143. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChatManager.java   (working copy)
  144. @@ -0,0 +1,111 @@
  145. +/*
  146. + * This program is free software: you can redistribute it and/or modify it under
  147. + * the terms of the GNU General Public License as published by the Free Software
  148. + * Foundation, either version 3 of the License, or (at your option) any later
  149. + * version.
  150. + *
  151. + * This program is distributed in the hope that it will be useful, but WITHOUT
  152. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  153. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  154. + * details.
  155. + *
  156. + * You should have received a copy of the GNU General Public License along with
  157. + * this program. If not, see <http://www.gnu.org/licenses/>.
  158. + */
  159. +package net.sf.l2j.gameserver.handler.admincommandhandlers;
  160. +
  161. +import java.util.StringTokenizer;
  162. +
  163. +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  164. +import net.sf.l2j.gameserver.handler.chathandlers.ChatHeroVoice;
  165. +import net.sf.l2j.gameserver.handler.chathandlers.ChatShout;
  166. +import net.sf.l2j.gameserver.handler.chathandlers.ChatTrade;
  167. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  168. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  169. +
  170. +public class AdminChatManager implements IAdminCommandHandler
  171. +{
  172. +   private static final String[] ADMIN_COMMANDS =
  173. +   {
  174. +       "admin_quiet"
  175. +   };
  176. +
  177. +   public boolean useAdminCommand(String command, L2PcInstance activeChar)
  178. +   {
  179. +       if (command.startsWith("admin_quiet"))
  180. +       {
  181. +           StringTokenizer st = new StringTokenizer(command);
  182. +           st.nextToken();
  183. +
  184. +           try
  185. +           {
  186. +               String type = st.nextToken();
  187. +               if (type.startsWith("all"))
  188. +               {
  189. +                   if (!Say2.isChatDisabled())
  190. +                   {
  191. +                       Say2.setIsChatDisabled(true);
  192. +                       activeChar.sendMessage("All chats have been disabled!");
  193. +                   }
  194. +                   else
  195. +                   {
  196. +                       Say2.setIsChatDisabled(false);
  197. +                       activeChar.sendMessage("All Chats have been enabled!");
  198. +                   }
  199. +               }
  200. +               else if (type.startsWith("hero"))
  201. +               {
  202. +                   if (!ChatHeroVoice.isChatDisabled())
  203. +                   {
  204. +                       ChatHeroVoice.setIsChatDisabled(true);
  205. +                       activeChar.sendMessage("Hero Voice has been disabled!");
  206. +                   }
  207. +                   else
  208. +                   {
  209. +                       ChatHeroVoice.setIsChatDisabled(false);
  210. +                       activeChar.sendMessage("Hero Voice has been enabled!");
  211. +                   }
  212. +               }
  213. +               else if (type.startsWith("trade"))
  214. +               {
  215. +                   if (!ChatTrade.isChatDisabled())
  216. +                   {
  217. +                       ChatTrade.setIsChatDisabled(true);
  218. +                       activeChar.sendMessage("Trade Chat has been disabled!");
  219. +                   }
  220. +                   else
  221. +                   {
  222. +                       ChatTrade.setIsChatDisabled(false);
  223. +                       activeChar.sendMessage("Trade Chat has been enabled!");
  224. +                   }
  225. +               }
  226. +               else if (type.startsWith("global"))
  227. +               {
  228. +                   if (!ChatShout.isChatDisabled())
  229. +                   {
  230. +                       ChatShout.setIsChatDisabled(true);
  231. +                       activeChar.sendMessage("Global Chat has been disabled!");
  232. +                   }
  233. +                   else
  234. +                   {
  235. +                       ChatShout.setIsChatDisabled(false);
  236. +                       activeChar.sendMessage("Global Chat has been enabled!");
  237. +                   }
  238. +               }
  239. +           }
  240. +           catch (Exception e)
  241. +           {
  242. +               activeChar.sendMessage("Usage : //quiet <all|hero|trade|global>");
  243. +           }
  244. +       }
  245. +       return true;
  246. +   }
  247. +
  248. +   public String[] getAdminCommandList()
  249. +   {
  250. +       return ADMIN_COMMANDS;
  251. +   }
  252. +}
  253. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java
  254. ===================================================================
  255. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java  (revision 10)
  256. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java  (working copy)
  257. @@ -19,6 +19,7 @@
  258.  import net.sf.l2j.gameserver.handler.IChatHandler;
  259.  import net.sf.l2j.gameserver.model.L2World;
  260.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  261. +import net.sf.l2j.gameserver.network.SystemMessageId;
  262.  import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  263.  
  264.  /**
  265. @@ -30,12 +31,20 @@
  266.  {
  267.     private static final int[] COMMAND_IDS = { 17 };
  268.  
  269. +   private static boolean _chatDisabled = false;
  270. +
  271.     /**
  272.      * Handle chat type 'hero voice'
  273.      * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  274.      */
  275.     public void handleChat(int type, L2PcInstance activeChar, String target, String text)
  276.     {
  277. +       if (isChatDisabled() && !activeChar.isGM())
  278. +       {
  279. +           activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
  280. +           return;
  281. +       }
  282. +
  283.         if (activeChar.isHero())
  284.         {
  285.             if (!activeChar.getFloodProtectors().getHeroVoice().tryPerformAction("heroVoice"))
  286. @@ -50,6 +59,22 @@
  287.     }
  288.  
  289.     /**
  290. +    * @return Returns the chatDisabled.
  291. +    */
  292. +   public static boolean isChatDisabled()
  293. +   {
  294. +       return _chatDisabled;
  295. +   }
  296. +
  297. +   /**
  298. +    * @param chatDisabled The chatDisabled to set.
  299. +    */
  300. +   public static void setIsChatDisabled(boolean chatDisabled)
  301. +   {
  302. +       _chatDisabled = chatDisabled;
  303. +   }
  304. +
  305. +   /**
  306.      * Returns the chat types registered to this handler
  307.      * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
  308.      */
  309. Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java
  310. ===================================================================
  311. --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java  (revision 10)
  312. +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java  (working copy)
  313. @@ -21,6 +21,7 @@
  314.  import net.sf.l2j.gameserver.model.BlockList;
  315.  import net.sf.l2j.gameserver.model.L2World;
  316.  import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  317. +import net.sf.l2j.gameserver.network.SystemMessageId;
  318.  import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  319.  
  320.  /**
  321. @@ -32,12 +33,20 @@
  322.  {
  323.     private static final int[] COMMAND_IDS = { 8 };
  324.  
  325. +   private static boolean _chatDisabled = false;
  326. +
  327.     /**
  328.      * Handle chat type 'trade'
  329.      * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
  330.      */
  331.     public void handleChat(int type, L2PcInstance activeChar, String target, String text)
  332.     {
  333. +       if (isChatDisabled() && !activeChar.isGM())
  334. +       {
  335. +           activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
  336. +           return;
  337. +       }
  338. +
  339.         CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
  340.         Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
  341.         int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
  342. @@ -51,6 +60,22 @@
  343.     }
  344.  
  345.     /**
  346. +    * @return Returns the chatDisabled.
  347. +    */
  348. +   public static boolean isChatDisabled()
  349. +   {
  350. +       return _chatDisabled;
  351. +   }
  352. +
  353. +   /**
  354. +    * @param chatDisabled The chatDisabled to set.
  355. +    */
  356. +   public static void setIsChatDisabled(boolean chatDisabled)
  357. +   {
  358. +       _chatDisabled = chatDisabled;
  359. +   }
  360. +
  361. +   /**
  362.      * Returns the chat types registered to this handler
  363.      * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
  364.      */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement