Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // VOICEMOIONADHANDER
- * 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();
- }
- }
- // online
- /*
- * 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.World;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- public class Online implements IVoicedCommandHandler
- {
- private static final String[] _voicedCommands =
- {
- "online"
- };
- @Override
- public boolean useVoicedCommand(String command, Player activeChar, String target)
- {
- if (command.equals("online"))
- {
- activeChar.sendMessage("====[Online Players]====");
- activeChar.sendMessage("Player(s): " + World.getInstance().getAllPlayersCount() * 1+ " Online.");
- activeChar.sendMessage("======[L2-Might]======");
- }
- return true;
- }
- @Override
- public String[] getVoicedCommandList()
- {
- return _voicedCommands;
- }
- }
- // IVoicedCommandHandler
- /*
- * 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.handler.IVoicedCommandHandler;
- import net.sf.l2j.gameserver.model.actor.instance.Player;
- import java.util.logging.Logger;
- public interface IVoicedCommandHandler
- {
- public static Logger _log = Logger.getLogger(IVoicedCommandHandler.class.getName());
- public boolean useVoicedCommand(String command, Player activeChar, String params);
- public String[] getVoicedCommandList();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement