Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/net/sf/l2j/gameserver/clientpackets/Say2.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/clientpackets/Say2.java (revision 2)
- +++ java/net/sf/l2j/gameserver/clientpackets/Say2.java (revision 5)
- @@ -26,15 +26,7 @@
- import net.sf.l2j.Config;
- -import net.sf.l2j.gameserver.datatables.MapRegionTable;
- -import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- -import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- -import net.sf.l2j.gameserver.instancemanager.PetitionManager;
- -import net.sf.l2j.gameserver.model.BlockList;
- -import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.handler.ChatHandler;
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- -import net.sf.l2j.gameserver.network.SystemMessageId;
- -import net.sf.l2j.gameserver.serverpackets.CreatureSay;
- -import net.sf.l2j.gameserver.serverpackets.SystemMessage;
- -import net.sf.l2j.gameserver.util.FloodProtector;
- /**
- @@ -156,172 +148,8 @@
- _logChat.log(record);
- }
- -
- - CreatureSay cs = new CreatureSay(activeChar.getObjectId(), _type, activeChar.getName(), _text);
- -
- - switch (_type)
- + IChatHandler handler = ChatHandler.getInstance().getChatHandler(_type);
- + if (handler != null)
- {
- - case TELL:
- - L2PcInstance receiver = L2World.getInstance().getPlayer(_target);
- -
- - if (receiver != null &&
- - !BlockList.isBlocked(receiver, activeChar))
- - {
- - if (Config.JAIL_DISABLE_CHAT && receiver.isInJail())
- - {
- - activeChar.sendMessage("Player is in jail.");
- - return;
- - }
- - if (receiver.isChatBanned())
- - {
- - activeChar.sendMessage("Player is chat banned.");
- - return;
- - }
- -
- - if (!receiver.getMessageRefusal())
- - {
- - receiver.sendPacket(cs);
- - activeChar.sendPacket(new CreatureSay(activeChar.getObjectId(), _type, "->" + receiver.getName(), _text));
- - }
- - else
- - {
- - activeChar.sendPacket(new SystemMessage(SystemMessageId.THE_PERSON_IS_IN_MESSAGE_REFUSAL_MODE));
- - }
- - }
- - else
- - {
- - SystemMessage sm = new SystemMessage(SystemMessageId.S1_IS_NOT_ONLINE);
- - sm.addString(_target);
- - activeChar.sendPacket(sm);
- - sm = null;
- - }
- - break;
- - case SHOUT:
- - if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") ||
- - (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
- - {
- - int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
- - for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- - {
- - if (region == MapRegionTable.getInstance().getMapRegion(player.getX(),player.getY()))
- - player.sendPacket(cs);
- - }
- - }
- - else if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("global"))
- - {
- - for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- - {
- - player.sendPacket(cs);
- - }
- - }
- - break;
- - case TRADE:
- - if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") ||
- - (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
- - {
- - for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- - {
- - player.sendPacket(cs);
- - }
- - } else if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("limited"))
- - {
- - int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
- - for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- - {
- - if (region == MapRegionTable.getInstance().getMapRegion(player.getX(),player.getY()))
- - player.sendPacket(cs);
- - }
- - }
- - break;
- - case ALL:
- - if (_text.startsWith("."))
- - {
- - StringTokenizer st = new StringTokenizer(_text);
- - IVoicedCommandHandler vch;
- - String command = "";
- - String target = "";
- -
- - if (st.countTokens() > 1)
- - {
- - command = st.nextToken().substring(1);
- - target = _text.substring(command.length() + 2);
- - vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
- - }
- - else
- - {
- - command = _text.substring(1);
- - if (Config.DEBUG) _log.info("Command: "+command);
- - vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
- - }
- - if (vch != null)
- - vch.useVoicedCommand(command, activeChar, target);
- - else
- - {
- - if (Config.DEBUG) _log.warning("No handler registered for bypass '"+command+"'");
- - }
- - }
- - else
- - {
- - for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
- - {
- - if (player != null && activeChar.isInsideRadius(player, 1250, false, true))
- - player.sendPacket(cs);
- - }
- - activeChar.sendPacket(cs);
- - }
- - break;
- - case CLAN:
- - if (activeChar.getClan() != null)
- - activeChar.getClan().broadcastToOnlineMembers(cs);
- - break;
- - case ALLIANCE:
- - if (activeChar.getClan() != null)
- - activeChar.getClan().broadcastToOnlineAllyMembers(cs);
- - break;
- - case PARTY:
- - if (activeChar.isInParty())
- - activeChar.getParty().broadcastToPartyMembers(cs);
- - break;
- - case PETITION_PLAYER:
- - case PETITION_GM:
- - if (!PetitionManager.getInstance().isPlayerInConsultation(activeChar))
- - {
- - activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_IN_PETITION_CHAT));
- - break;
- - }
- -
- - PetitionManager.getInstance().sendActivePetitionMessage(activeChar, _text);
- - break;
- - case PARTYROOM_ALL:
- - if (activeChar.isInParty())
- - {
- - if (activeChar.getParty().isInCommandChannel() && activeChar.getParty().isLeader(activeChar))
- - {
- - activeChar.getParty().getCommandChannel().broadcastToChannelMembers(cs);
- - }
- - }
- - break;
- - case PARTYROOM_COMMANDER:
- - if (activeChar.isInParty())
- - {
- - if (activeChar.getParty().isInCommandChannel() &&
- - activeChar.getParty().getCommandChannel().getChannelLeader().equals(activeChar))
- - {
- - activeChar.getParty().getCommandChannel().broadcastToChannelMembers(cs);
- - }
- - }
- - break;
- - case HERO_VOICE:
- - if (activeChar.isHero())
- - {
- - if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_HEROVOICE))
- - {
- - activeChar.sendMessage("Action failed. Heroes are only able to speak in the global channel once every 10 seconds.");
- - return;
- - }
- - for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- - if (!BlockList.isBlocked(player, activeChar))
- - player.sendPacket(cs);
- - }
- - break;
- + handler.handleChat(_type, activeChar, _target, _text);
- }
- }
- Index: java/net/sf/l2j/gameserver/handler/ChatHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/ChatHandler.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/ChatHandler.java (revision 5)
- @@ -0,0 +1,84 @@
- +/*
- + * 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;
- +
- +import java.util.logging.Logger;
- +
- +import javolution.util.FastMap;
- +import net.sf.l2j.Config;
- +
- + /**
- + * This class handles all chat handlers
- + *
- + * @author durgus
- + */
- +public class ChatHandler
- +{
- + private static Logger _log = Logger.getLogger(ChatHandler.class.getName());
- +
- + private static ChatHandler _instance;
- +
- + private FastMap<Integer, IChatHandler> _datatable;
- +
- + public static ChatHandler getInstance()
- + {
- + if (_instance == null)
- + {
- + _instance = new ChatHandler();
- + }
- + return _instance;
- + }
- +
- + /**
- + * Singleton constructor
- + */
- + private ChatHandler()
- + {
- + _datatable = new FastMap<Integer, IChatHandler>();
- + }
- +
- + /**
- + * Register a new chat handler
- + * @param handler
- + */
- + public void registerChatHandler(IChatHandler handler)
- + {
- + int[] ids = handler.getChatTypeList();
- + for (int i = 0; i < ids.length; i++)
- + {
- + if (Config.DEBUG) _log.fine("Adding handler for chat type "+ids[i]);
- + _datatable.put(ids[i], handler);
- + }
- + }
- +
- + /**
- + * Get the chat handler for the given chat type
- + * @param chatType
- + * @return
- + */
- + public IChatHandler getChatHandler(int chatType)
- + {
- + return _datatable.get(chatType);
- + }
- +
- + /**
- + * Returns the size
- + * @return
- + */
- + public int size()
- + {
- + return _datatable.size();
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatParty.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatParty.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatParty.java (revision 5)
- @@ -0,0 +1,52 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.serverpackets.CreatureSay;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatParty implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 3 };
- +
- + /**
- + * Handle chat type 'party'
- + * @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 (activeChar.isInParty())
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- +
- + activeChar.getParty().broadcastToPartyMembers(cs);
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatTrade.java (revision 5)
- @@ -0,0 +1,69 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.datatables.MapRegionTable;
- +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.serverpackets.CreatureSay;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatTrade implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 8 };
- +
- + /**
- + * 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)
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- +
- + if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
- + {
- + for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- + {
- + player.sendPacket(cs);
- + }
- + }
- + else if (Config.DEFAULT_TRADE_CHAT.equalsIgnoreCase("limited"))
- + {
- + int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
- + for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- + {
- + if (region == MapRegionTable.getInstance().getMapRegion(player.getX(),player.getY()))
- + {
- + player.sendPacket(cs);
- + }
- + }
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatTell.java (revision 5)
- @@ -0,0 +1,91 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +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.serverpackets.CreatureSay;
- +import net.sf.l2j.gameserver.serverpackets.SystemMessage;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatTell implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 2 };
- +
- + /**
- + * Handle chat type 'tell'
- + * @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)
- + {
- + // Return if no target is set
- + if (target == null) return;
- +
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- + L2PcInstance receiver = null;
- +
- + receiver = L2World.getInstance().getPlayer(target);
- +
- + if (receiver != null && !BlockList.isBlocked(receiver, activeChar))
- + {
- + if (Config.JAIL_DISABLE_CHAT && receiver.isInJail())
- + {
- + activeChar.sendMessage("Player is in jail.");
- + return;
- + }
- +
- +
- + if (receiver.isChatBanned())
- + {
- + activeChar.sendMessage("Player is chat banned.");
- + return;
- + }
- +
- + if (!receiver.getMessageRefusal())
- + {
- + receiver.sendPacket(cs);
- + activeChar.sendPacket(new CreatureSay(activeChar.getObjectId(), type, "->" + receiver.getName(), text));
- + }
- + else
- + {
- + activeChar.sendPacket(new SystemMessage(SystemMessageId.THE_PERSON_IS_IN_MESSAGE_REFUSAL_MODE));
- + }
- + }
- + else
- + {
- + SystemMessage sm = new SystemMessage(SystemMessageId.S1_IS_NOT_ONLINE);
- + sm.addString(target);
- + activeChar.sendPacket(sm);
- + sm = null;
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatPartyRoomCommander.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatPartyRoomCommander.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatPartyRoomCommander.java (revision 5)
- @@ -0,0 +1,54 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.serverpackets.CreatureSay;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatPartyRoomCommander implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 15 };
- +
- + /**
- + * Handle chat type 'party room commander'
- + * @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 (activeChar.isInParty())
- + {
- + if (activeChar.getParty().isInCommandChannel() && activeChar.getParty().getCommandChannel().getChannelLeader().equals(activeChar))
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- + activeChar.getParty().getCommandChannel().broadcastToChannelMembers(cs);
- + }
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatShout.java (revision 5)
- @@ -0,0 +1,69 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.datatables.MapRegionTable;
- +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.serverpackets.CreatureSay;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatShout implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 1 };
- +
- + /**
- + * 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)
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- +
- + if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("on") || (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("gm") && activeChar.isGM()))
- + {
- + int region = MapRegionTable.getInstance().getMapRegion(activeChar.getX(), activeChar.getY());
- + for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- + {
- + if (region == MapRegionTable.getInstance().getMapRegion(player.getX(),player.getY()))
- + {
- + player.sendPacket(cs);
- + }
- + }
- + }
- + else if (Config.DEFAULT_GLOBAL_CHAT.equalsIgnoreCase("global"))
- + {
- + for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- + {
- + player.sendPacket(cs);
- + }
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatHeroVoice.java (revision 5)
- @@ -0,0 +1,67 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +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.serverpackets.CreatureSay;
- +import net.sf.l2j.gameserver.util.FloodProtector;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatHeroVoice implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 17 };
- +
- + /**
- + * 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 (activeChar.isHero() || activeChar.isGM())
- + {
- + if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_HEROVOICE))
- + {
- + activeChar.sendMessage("Action failed. Heroes are only able to speak in the global channel once every 10 seconds.");
- + return;
- + }
- +
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- +
- + for (L2PcInstance player : L2World.getInstance().getAllPlayers())
- + {
- + if (!BlockList.isBlocked(player, activeChar))
- + {
- + player.sendPacket(cs);
- + }
- + }
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatPartyRoomAll.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatPartyRoomAll.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatPartyRoomAll.java (revision 5)
- @@ -0,0 +1,54 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.serverpackets.CreatureSay;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatPartyRoomAll implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 16 };
- +
- + /**
- + * Handle chat type 'party room all'
- + * @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 (activeChar.isInParty())
- + {
- + if (activeChar.getParty().isInCommandChannel() && activeChar.getParty().isLeader(activeChar))
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- + activeChar.getParty().getCommandChannel().broadcastToChannelMembers(cs);
- + }
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 5)
- @@ -0,0 +1,94 @@
- +/*
- + * 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.chathandlers;
- +
- +import java.util.StringTokenizer;
- +import java.util.logging.Logger;
- +
- +import net.sf.l2j.Config;
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.serverpackets.CreatureSay;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatAll implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 0 };
- + private static Logger _log = Logger.getLogger(ChatAll.class.getName());
- +
- + /**
- + * Handle chat type 'all'
- + * @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 (text.startsWith("."))
- + {
- + StringTokenizer st = new StringTokenizer(text);
- + IVoicedCommandHandler vch;
- + String command = "";
- +
- + if (st.countTokens() > 1)
- + {
- + command = st.nextToken().substring(1);
- + target = text.substring(command.length() + 2);
- + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
- + }
- + else
- + {
- + command = text.substring(1);
- + if (Config.DEBUG) _log.info("Command: "+command);
- + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
- + }
- + if (vch != null)
- + {
- + vch.useVoicedCommand(command, activeChar, target);
- + }
- + else
- + {
- + if (Config.DEBUG) _log.warning("No handler registered for bypass '"+command+"'");
- + }
- + }
- + else
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- +
- + for (L2PcInstance player : activeChar.getKnownList().getKnownPlayers().values())
- + {
- + if (player != null && activeChar.isInsideRadius(player, 1250, false, true))
- + {
- + player.sendPacket(cs);
- + }
- + }
- +
- + activeChar.sendPacket(cs);
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAlliance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAlliance.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAlliance.java (revision 5)
- @@ -0,0 +1,46 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.serverpackets.CreatureSay;
- +
- +public class ChatAlliance implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 9 };
- +
- + /**
- + * Handle chat type 'alliance'
- + * @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 (activeChar.getClan() != null)
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- + activeChar.getClan().broadcastToOnlineAllyMembers(cs);
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatPetition.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatPetition.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatPetition.java (revision 5)
- @@ -0,0 +1,55 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.instancemanager.PetitionManager;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.network.SystemMessageId;
- +import net.sf.l2j.gameserver.serverpackets.SystemMessage;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatPetition implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 6, 7 };
- +
- + /**
- + * Handle chat type 'petition player'
- + * @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 (!PetitionManager.getInstance().isPlayerInConsultation(activeChar))
- + {
- + activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_IN_PETITION_CHAT));
- + return;
- + }
- +
- + PetitionManager.getInstance().sendActivePetitionMessage(activeChar, text);
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatClan.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatClan.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatClan.java (revision 5)
- @@ -0,0 +1,51 @@
- +/*
- + * 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.chathandlers;
- +
- +import net.sf.l2j.gameserver.handler.IChatHandler;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.serverpackets.CreatureSay;
- +
- +/**
- + * A chat handler
- + *
- + * @author durgus
- + */
- +public class ChatClan implements IChatHandler
- +{
- + private static final int[] COMMAND_IDS = { 4 };
- +
- + /**
- + * Handle chat type 'clan'
- + * @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 (activeChar.getClan() != null)
- + {
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- + activeChar.getClan().broadcastToOnlineMembers(cs);
- + }
- + }
- +
- + /**
- + * Returns the chat types registered to this handler
- + * @see net.sf.l2j.gameserver.handler.IChatHandler#getChatTypeList()
- + */
- + public int[] getChatTypeList()
- + {
- + return COMMAND_IDS;
- + }
- +}
- Index: java/net/sf/l2j/gameserver/handler/IChatHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/IChatHandler.java (revision 5)
- +++ java/net/sf/l2j/gameserver/handler/IChatHandler.java (revision 5)
- @@ -0,0 +1,39 @@
- +/*
- + * 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;
- +
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +/**
- + * Interface for chat handlers
- + *
- + * @author durgus
- + */
- +public interface IChatHandler
- +{
- + /**
- + * Handles a specific type of chat messages
- + * @param type
- + * @param activeChar
- + * @param target
- + */
- + public void handleChat(int type, L2PcInstance activeChar, String target, String text);
- +
- + /**
- + * Returns a list of all chat types registered to this handler
- + * @return
- + */
- + public int[] getChatTypeList();
- +}
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 2)
- +++ java/net/sf/l2j/gameserver/GameServer.java (revision 5)
- @@ -63,4 +63,5 @@
- import net.sf.l2j.gameserver.geoeditorcon.GeoEditorListener;
- import net.sf.l2j.gameserver.handler.AdminCommandHandler;
- +import net.sf.l2j.gameserver.handler.ChatHandler;
- import net.sf.l2j.gameserver.handler.ItemHandler;
- import net.sf.l2j.gameserver.handler.SkillHandler;
- @@ -121,4 +122,15 @@
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminUnblockIp;
- import net.sf.l2j.gameserver.handler.admincommandhandlers.AdminZone;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatAll;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatAlliance;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatClan;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatHeroVoice;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatParty;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatPartyRoomAll;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatPartyRoomCommander;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatPetition;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatShout;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatTell;
- +import net.sf.l2j.gameserver.handler.chathandlers.ChatTrade;
- import net.sf.l2j.gameserver.handler.itemhandlers.BeastSoulShot;
- import net.sf.l2j.gameserver.handler.itemhandlers.BeastSpice;
- @@ -256,4 +268,5 @@
- private final UserCommandHandler _userCommandHandler;
- private final VoicedCommandHandler _voicedCommandHandler;
- + private final ChatHandler _chatHandler;
- private final DoorTable _doorTable;
- private final SevenSigns _sevenSignsEngine;
- @@ -587,4 +600,19 @@
- _log.config("UserCommandHandler: Loaded " + _userCommandHandler.size() + " handlers.");
- +
- + _chatHandler = ChatHandler.getInstance();
- + _chatHandler.registerChatHandler(new ChatAll());
- + _chatHandler.registerChatHandler(new ChatAlliance());
- + _chatHandler.registerChatHandler(new ChatClan());
- + _chatHandler.registerChatHandler(new ChatHeroVoice());
- + _chatHandler.registerChatHandler(new ChatParty());
- + _chatHandler.registerChatHandler(new ChatPartyRoomAll());
- + _chatHandler.registerChatHandler(new ChatPartyRoomCommander());
- + _chatHandler.registerChatHandler(new ChatPetition());
- + _chatHandler.registerChatHandler(new ChatShout());
- + _chatHandler.registerChatHandler(new ChatTell());
- + _chatHandler.registerChatHandler(new ChatTrade());
- +
- + _log.config("ChatHandler: Loaded " + _chatHandler.size() + " handlers.");
- _voicedCommandHandler = VoicedCommandHandler.getInstance();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement