Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P aCis_gameserver
- Index: java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java (working copy)
- @@ -0,0 +1,24 @@
- +/*
- + * 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;
- +
- +public interface IVoicedCommandHandler
- +{
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params);
- +
- + public String[] getVoicedCommandList();
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (revision 1)
- +++ java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java (working copy)
- @@ -14,7 +14,11 @@
- */
- package net.sf.l2j.gameserver.handler.chathandlers;
- +import java.util.StringTokenizer;
- +
- 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.BlockList;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
- @@ -37,15 +41,43 @@
- @Override
- public void handleChat(int type, L2PcInstance activeChar, String params, String text)
- {
- - CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- + boolean vcd_used = false;
- + if (text.startsWith("."))
- + {
- + StringTokenizer st = new StringTokenizer(text);
- + IVoicedCommandHandler vch;
- + String command = "";
- - for (L2PcInstance player : activeChar.getKnownList().getKnownTypeInRadius(L2PcInstance.class, 1250))
- + if (st.countTokens() > 1)
- + {
- + command = st.nextToken().substring(1);
- + params = text.substring(command.length() + 2);
- + vch = VoicedCommandHandler.getInstance().getHandler(command);
- + }
- + else
- + {
- + command = text.substring(1);
- + vch = VoicedCommandHandler.getInstance().getHandler(command);
- + }
- +
- + if (vch != null)
- + {
- + vch.useVoicedCommand(command, activeChar, params);
- + vcd_used = true;
- + }
- + }
- + if (!vcd_used)
- {
- - if (!BlockList.isBlocked(player, activeChar))
- - player.sendPacket(cs);
- - }
- -
- - activeChar.sendPacket(cs);
- + CreatureSay cs = new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
- +
- + for (L2PcInstance player : activeChar.getKnownList().getKnownTypeInRadius(L2PcInstance.class, 1250))
- + {
- + if (!BlockList.isBlocked(player, activeChar))
- + player.sendPacket(cs);
- + }
- +
- + activeChar.sendPacket(cs);
- + }
- }
- /**
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 1)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -63,6 +63,7 @@
- import net.sf.l2j.gameserver.handler.ItemHandler;
- import net.sf.l2j.gameserver.handler.SkillHandler;
- import net.sf.l2j.gameserver.handler.UserCommandHandler;
- +import net.sf.l2j.gameserver.handler.VoicedCommandHandler;
- import net.sf.l2j.gameserver.idfactory.IdFactory;
- import net.sf.l2j.gameserver.instancemanager.AuctionManager;
- import net.sf.l2j.gameserver.instancemanager.BoatManager;
- @@ -275,7 +276,8 @@
- _log.config("ItemHandler: Loaded " + ItemHandler.getInstance().size() + " handlers.");
- _log.config("SkillHandler: Loaded " + SkillHandler.getInstance().size() + " handlers.");
- _log.config("UserCommandHandler: Loaded " + UserCommandHandler.getInstance().size() + " handlers.");
- -
- + _log.config("VoicedCommandHandler: Loaded " + VoicedCommandHandler.getInstance().size() + " handlers.");
- +
- if (Config.ALLOW_WEDDING)
- CoupleManager.getInstance();
- Index: java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/voicedcommandhandlers/Online.java (working copy)
- @@ -0,0 +1,42 @@
- +/*
- + * 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.voicedcommandhandlers;
- +
- +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler;
- +import net.sf.l2j.gameserver.model.L2World;
- +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +
- +public class Online implements IVoicedCommandHandler
- +{
- + private static final String[] _voicedCommands = {"online"};
- +
- + @Override
- + public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
- + {
- + if (command.equals("online"))
- + {
- + activeChar.sendMessage("====[Online Players]====");
- + activeChar.sendMessage("Player(s): " + L2World.getInstance().getAllPlayersCount() + " Online.");
- + activeChar.sendMessage("======[L2jFanatic]======");
- + }
- + return true;
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- + return _voicedCommands;
- + }
- +}
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (revision 0)
- +++ java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java (working copy)
- @@ -0,0 +1,64 @@
- +/*
- + * 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.HashMap;
- +import java.util.Map;
- +
- +import net.sf.l2j.gameserver.handler.voicedcommandhandlers.Online;
- +
- +public class VoicedCommandHandler
- +{
- + private final Map<Integer, IVoicedCommandHandler> _datatable = new HashMap<>();
- +
- + public static VoicedCommandHandler getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + protected VoicedCommandHandler()
- + {
- + // coloque aqui os comandos
- + registerHandler(new Online());
- + }
- +
- + public void registerHandler(IVoicedCommandHandler handler)
- + {
- + String[] ids = handler.getVoicedCommandList();
- +
- + for (int i = 0; i < ids.length; i++)
- + _datatable.put(ids[i].hashCode(), handler);
- + }
- +
- + public IVoicedCommandHandler getHandler(String voicedCommand)
- + {
- + String command = voicedCommand;
- +
- + if (voicedCommand.indexOf(" ") != -1)
- + command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
- +
- + return _datatable.get(command.hashCode());
- + }
- +
- + public int size()
- + {
- + return _datatable.size();
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement