Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: sql/admin_command_access_rights.sql
- ===================================================================
- --- sql/admin_command_access_rights.sql (revision 984)
- +++ sql/admin_command_access_rights.sql (working copy)
- @@ -77,6 +77,9 @@
- -- Section: ChangeLevel
- ('admin_changelvl','2'),
- +-- Section: ChatManager
- +('admin_quiet','1'),
- +
- -- Section: Christmas
- ('admin_christmas_start','3'),
- ('admin_christmas_end','3'),
- Index: head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminChatManager.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminChatManager.java (revision 0)
- +++ head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminChatManager.java (working copy)
- @@ -0,0 +1,107 @@
- +/*
- + * 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 com.l2jfrozen.gameserver.handler.admincommandhandlers;
- +
- +import java.util.StringTokenizer;
- +
- +import com.l2jfrozen.gameserver.handler.IAdminCommandHandler;
- +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
- +import com.l2jfrozen.gameserver.network.clientpackets.Say2;
- +
- +public class AdminChatManager implements IAdminCommandHandler
- +{
- + private static final String[] ADMIN_COMMANDS =
- + {
- + "admin_quiet"
- + };
- +
- + @Override
- + 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("all"))
- + {
- + Say2.setIsChatDisabled("all", true);
- + activeChar.sendMessage("All chats have been disabled! ");
- + }
- + else
- + {
- + Say2.setIsChatDisabled("all", false);
- + activeChar.sendMessage("All Chats have been enabled!");
- + }
- + }
- + else if (type.startsWith("hero"))
- + {
- + if (!Say2.isChatDisabled("hero"))
- + {
- + Say2.setIsChatDisabled("hero", true);
- + activeChar.sendMessage("Hero Voice has been disabled!");
- + }
- + else
- + {
- + Say2.setIsChatDisabled("hero", false);
- + activeChar.sendMessage("Hero Voice has been enabled!");
- + }
- + }
- + else if (type.startsWith("trade"))
- + {
- + if (!Say2.isChatDisabled("trade"))
- + {
- + Say2.setIsChatDisabled("trade", true);
- + activeChar.sendMessage("Trade Chat has been disabled!");
- + }
- + else
- + {
- + Say2.setIsChatDisabled("trade", false);
- + activeChar.sendMessage("Trade Chat has been enabled!");
- + }
- + }
- + else if (type.startsWith("global"))
- + {
- + if (!Say2.isChatDisabled("global"))
- + {
- + Say2.setIsChatDisabled("global", true);
- + activeChar.sendMessage("Global Chat has been disabled!");
- + }
- + else
- + {
- + Say2.setIsChatDisabled("global", false);
- + activeChar.sendMessage("Global Chat has been enabled!");
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + activeChar.sendMessage("Usage : //quiet <all|hero|trade|global>");
- + }
- + }
- + return true;
- + }
- +
- + @Override
- + public String[] getAdminCommandList()
- + {
- + return ADMIN_COMMANDS;
- + }
- +}
- Index: head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java (revision 984)
- +++ head-src/com/l2jfrozen/gameserver/network/clientpackets/Say2.java (working copy)
- @@ -83,6 +83,11 @@
- private SystemChatChannelId _type2Check;
- private String _target;
- + private static boolean _chatDisabled = false;
- + private static boolean _globalChatDisabled = false;
- + private static boolean _tradeChatDisabled = false;
- + private static boolean _heroChatDisabled = false;
- +
- @Override
- protected void readImpl()
- {
- @@ -138,6 +143,12 @@
- return;
- }
- + if (isChatDisabled("all") && !activeChar.isGM())
- + {
- + activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
- + return;
- + }
- +
- if( activeChar.isChatBanned() && !activeChar.isGM() && _type != CLAN && _type != ALLIANCE && _type != PARTY)
- {
- activeChar.sendMessage("You may not chat while a chat ban is in effect.");
- @@ -346,6 +357,12 @@
- if (!getClient().getFloodProtectors().getGlobalChat().tryPerformAction("global chat"))
- return;
- + if (isChatDisabled("global") && !activeChar.isGM())
- + {
- + activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
- + return;
- + }
- +
- if(Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") || Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.isGM())
- {
- int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
- @@ -387,6 +404,12 @@
- }
- break;
- case TRADE:
- + if (isChatDisabled("trade") && !activeChar.isGM())
- + {
- + activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
- + return;
- + }
- +
- if(Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("ON"))
- {
- if(Config.TRADE_CHAT_WITH_PVP)
- @@ -543,6 +566,12 @@
- }
- break;
- case HERO_VOICE:
- + if (isChatDisabled("hero") && !activeChar.isGM())
- + {
- + activeChar.sendPacket(new SystemMessage(SystemMessageId.GM_NOTICE_CHAT_DISABLED));
- + return;
- + }
- +
- if(activeChar.isGM())
- {
- for(L2PcInstance player : L2World.getInstance().getAllPlayers()){
- @@ -623,6 +652,34 @@
- }
- }
- + public static boolean isChatDisabled(String chatType)
- + {
- + boolean chatDisabled = false;
- +
- + if(chatType.equalsIgnoreCase("all"))
- + chatDisabled = _chatDisabled;
- + else if(chatType.equalsIgnoreCase("hero"))
- + chatDisabled = _heroChatDisabled;
- + else if(chatType.equalsIgnoreCase("trade"))
- + chatDisabled = _tradeChatDisabled;
- + else if(chatType.equalsIgnoreCase("global"))
- + chatDisabled = _globalChatDisabled;
- +
- + return chatDisabled;
- + }
- +
- + public static void setIsChatDisabled(String chatType, boolean chatDisabled)
- + {
- + if(chatType.equalsIgnoreCase("all"))
- + _chatDisabled = chatDisabled;
- + else if(chatType.equalsIgnoreCase("hero"))
- + _heroChatDisabled = chatDisabled;
- + else if(chatType.equalsIgnoreCase("trade"))
- + _tradeChatDisabled = chatDisabled;
- + else if(chatType.equalsIgnoreCase("global"))
- + _globalChatDisabled = chatDisabled;
- + }
- +
- @Override
- public String getType()
- {
- Index: head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java (revision 984)
- +++ head-src/com/l2jfrozen/gameserver/handler/AdminCommandHandler.java (working copy)
- @@ -36,6 +36,7 @@
- import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCache;
- import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminChangeAccessLevel;
- import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCharSupervision;
- +import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminChatManager;
- import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminChristmas;
- import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCreateItem;
- import com.l2jfrozen.gameserver.handler.admincommandhandlers.AdminCursedWeapons;
- @@ -185,6 +186,7 @@
- registerAdminCommandHandler(new AdminBuffs());
- registerAdminCommandHandler(new AdminAio());
- registerAdminCommandHandler(new AdminCharSupervision());
- + registerAdminCommandHandler(new AdminChatManager());
- registerAdminCommandHandler(new AdminWho()); // L2OFF command
- // ATTENTION: adding new command handlers, you have to change the
- // sql file containing the access levels rights
- Index: head-src/com/l2jfrozen/gameserver/network/SystemMessageId.java
- ===================================================================
- --- head-src/com/l2jfrozen/gameserver/network/SystemMessageId.java (revision 984)
- +++ head-src/com/l2jfrozen/gameserver/network/SystemMessageId.java (working copy)
- @@ -2114,6 +2114,12 @@
- CANNOT_GIVE_ITEMS_TO_DEAD_PET(590),
- /**
- + * ID: 599<br>
- + * Message: The GM has an important notice. Chat has been temporarily disabled.
- + */
- + GM_NOTICE_CHAT_DISABLED(599),
- +
- + /**
- * ID: 600<br>
- * Message: You may not equip a pet item.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement