Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: data/xml/admin_commands_rights.xml
- ===================================================================
- --- data/xml/admin_commands_rights.xml (revision 10)
- +++ data/xml/admin_commands_rights.xml (working copy)
- @@ -54,6 +54,9 @@
- <!-- CHANGE ACCESS LEVEL -->
- <aCar name="admin_changelvl" accessLevel="1" />
- + <!-- CHAT MANAGER -->
- + <aCar name="admin_quiet" accessLevel="1" />
- +
- <!-- CREATE ITEM -->
- <aCar name="admin_itemcreate" accessLevel="1" />
- <aCar name="admin_create_item" accessLevel="1" />
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java (revision 10)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java (working copy)
- @@ -21,6 +21,7 @@
- import net.sf.l2j.gameserver.model.BlockList;
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- /**
- @@ -32,12 +33,20 @@
- {
- private static final int[] COMMAND_IDS = { 1 };
- + private static boolean _chatDisabled = false;
- +
- /**
- * Handle chat type 'shout'
- * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
- */
- public void handleChat(int type, L2PcInstance activeChar, String target, String text)
- {
- + if (isChatDisabled() && !activeChar.isGM())
- + {
- + activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
- + return;
- + }
- +
- CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- Collection<L2PcInstance> pls = null;
- switch (activeChar.getFactionId()) {
- @@ -68,6 +77,22 @@
- }
- /**
- + * @return Returns the chatDisabled.
- + */
- + public static boolean isChatDisabled()
- + {
- + return _chatDisabled;
- + }
- +
- + /**
- + * @param chatDisabled The chatDisabled to set.
- + */
- + public static void setIsChatDisabled(boolean chatDisabled)
- + {
- + _chatDisabled = chatDisabled;
- + }
- +
- + /**
- * Returns the chat types registered to this handler
- * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- */
- Index: java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (revision 10)
- +++ java/net/sf/l2j/gameserver/network/clientpackets/Say2.java (working copy)
- @@ -81,6 +81,8 @@
- private int _type;
- private String _target;
- + private static boolean _chatDisabled = false;
- +
- @Override
- protected void readImpl()
- {
- @@ -99,6 +101,12 @@
- if (activeChar == null)
- return;
- + if (isChatDisabled() && !activeChar.isGM())
- + {
- + activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
- + return;
- + }
- +
- if (_type < 0 || _type >= CHAT_NAMES.length)
- {
- _log.warning("Say2: Invalid type: " +_type + " Player : " + activeChar.getName() + " text: " + String.valueOf(_text));
- @@ -172,6 +180,22 @@
- return false;
- }
- + /**
- + * @return Returns the chatDisabled.
- + */
- + public static boolean isChatDisabled()
- + {
- + return _chatDisabled;
- + }
- +
- + /**
- + * @param chatDisabled The chatDisabled to set.
- + */
- + public static void setIsChatDisabled(boolean chatDisabled)
- + {
- + _chatDisabled = chatDisabled;
- + }
- +
- @Override
- protected boolean triggersOnActionRequest()
- {
- Index: java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (revision 10)
- +++ java/net/sf/l2j/gameserver/handler/AdminCommandHandler.java (working copy)
- @@ -26,6 +26,7 @@
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCache;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCamera;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminChangeAccessLevel;
- +import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminChatManager;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCreateItem;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminDelete;
- @@ -88,6 +89,7 @@
- registerAdminCommandHandler(new AdminCache());
- registerAdminCommandHandler(new AdminCamera());
- registerAdminCommandHandler(new AdminChangeAccessLevel());
- + registerAdminCommandHandler(new AdminChatManager());
- registerAdminCommandHandler(new AdminCreateItem());
- registerAdminCommandHandler(new AdminCursedWeapons());
- registerAdminCommandHandler(new AdminDelete());
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChatManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChatManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminChatManager.java (working copy)
- @@ -0,0 +1,111 @@
- +/*
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.handler.admincommandhandlers;
- +
- +import java.util.StringTokenizer;
- +
- +import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatHeroVoice;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatShout;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatTrade;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.clientpackets.Say2;
- +
- +public class AdminChatManager implements IAdminCommandHandler
- +{
- + private static final String[] ADMIN_COMMANDS =
- + {
- + "admin_quiet"
- + };
- +
- + public boolean useAdminCommand(String command, L2PcInstance activeChar)
- + {
- + if (command.startsWith("admin_quiet"))
- + {
- + StringTokenizer st = new StringTokenizer(command);
- + st.nextToken();
- +
- + try
- + {
- + String type = st.nextToken();
- + if (type.startsWith("all"))
- + {
- + if (!Say2.isChatDisabled())
- + {
- + Say2.setIsChatDisabled(true);
- + activeChar.sendMessage("All chats have been disabled!");
- + }
- + else
- + {
- + Say2.setIsChatDisabled(false);
- + activeChar.sendMessage("All Chats have been enabled!");
- + }
- + }
- + else if (type.startsWith("hero"))
- + {
- + if (!ChatHeroVoice.isChatDisabled())
- + {
- + ChatHeroVoice.setIsChatDisabled(true);
- + activeChar.sendMessage("Hero Voice has been disabled!");
- + }
- + else
- + {
- + ChatHeroVoice.setIsChatDisabled(false);
- + activeChar.sendMessage("Hero Voice has been enabled!");
- + }
- + }
- + else if (type.startsWith("trade"))
- + {
- + if (!ChatTrade.isChatDisabled())
- + {
- + ChatTrade.setIsChatDisabled(true);
- + activeChar.sendMessage("Trade Chat has been disabled!");
- + }
- + else
- + {
- + ChatTrade.setIsChatDisabled(false);
- + activeChar.sendMessage("Trade Chat has been enabled!");
- + }
- + }
- + else if (type.startsWith("global"))
- + {
- + if (!ChatShout.isChatDisabled())
- + {
- + ChatShout.setIsChatDisabled(true);
- + activeChar.sendMessage("Global Chat has been disabled!");
- + }
- + else
- + {
- + ChatShout.setIsChatDisabled(false);
- + activeChar.sendMessage("Global Chat has been enabled!");
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + activeChar.sendMessage("Usage : //quiet <all|hero|trade|global>");
- + }
- + }
- + return true;
- + }
- +
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java (revision 10)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java (working copy)
- @@ -19,6 +19,7 @@
- import net.sf.l2j.gameserver.handler.IChatHandler;
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- /**
- @@ -30,12 +31,20 @@
- {
- private static final int[] COMMAND_IDS = { 17 };
- + private static boolean _chatDisabled = false;
- +
- /**
- * Handle chat type 'hero voice'
- * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
- */
- public void handleChat(int type, L2PcInstance activeChar, String target, String text)
- {
- + if (isChatDisabled() && !activeChar.isGM())
- + {
- + activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
- + return;
- + }
- +
- if (activeChar.isHero())
- {
- if (!activeChar.getFloodProtectors().getHeroVoice().tryPerformAction("heroVoice"))
- @@ -50,6 +59,22 @@
- }
- /**
- + * @return Returns the chatDisabled.
- + */
- + public static boolean isChatDisabled()
- + {
- + return _chatDisabled;
- + }
- +
- + /**
- + * @param chatDisabled The chatDisabled to set.
- + */
- + public static void setIsChatDisabled(boolean chatDisabled)
- + {
- + _chatDisabled = chatDisabled;
- + }
- +
- + /**
- * Returns the chat types registered to this handler
- * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- */
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java (revision 10)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java (working copy)
- @@ -21,6 +21,7 @@
- import net.sf.l2j.gameserver.model.BlockList;
- import net.sf.l2j.gameserver.model.L2World;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- /**
- @@ -32,12 +33,20 @@
- {
- private static final int[] COMMAND_IDS = { 8 };
- + private static boolean _chatDisabled = false;
- +
- /**
- * Handle chat type 'trade'
- * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int, net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
- */
- public void handleChat(int type, L2PcInstance activeChar, String target, String text)
- {
- + if (isChatDisabled() && !activeChar.isGM())
- + {
- + activeChar.sendPacket(SystemMessageId.GM_NOTICE_CHAT_DISABLED);
- + return;
- + }
- +
- CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
- int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
- @@ -51,6 +60,22 @@
- }
- /**
- + * @return Returns the chatDisabled.
- + */
- + public static boolean isChatDisabled()
- + {
- + return _chatDisabled;
- + }
- +
- + /**
- + * @param chatDisabled The chatDisabled to set.
- + */
- + public static void setIsChatDisabled(boolean chatDisabled)
- + {
- + _chatDisabled = chatDisabled;
- + }
- +
- + /**
- * Returns the chat types registered to this handler
- * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement