SHOW:
|
|
- or go back to the newest paste.
| 1 | diff --git a/java/net/sf/l2j/gameserver/GameServer.java b/java/net/sf/l2j/gameserver/GameServer.java | |
| 2 | index 6c1638e..7081406 100644 | |
| 3 | --- a/java/net/sf/l2j/gameserver/GameServer.java | |
| 4 | +++ b/java/net/sf/l2j/gameserver/GameServer.java | |
| 5 | @@ -81,6 +81,7 @@ | |
| 6 | import net.sf.l2j.gameserver.handler.SkillHandler; | |
| 7 | import net.sf.l2j.gameserver.handler.TargetHandler; | |
| 8 | import net.sf.l2j.gameserver.handler.UserCommandHandler; | |
| 9 | +import net.sf.l2j.gameserver.handler.VoicedCommandHandler; | |
| 10 | import net.sf.l2j.gameserver.idfactory.IdFactory; | |
| 11 | import net.sf.l2j.gameserver.model.World; | |
| 12 | import net.sf.l2j.gameserver.model.boat.BoatGiranTalking; | |
| 13 | @@ -274,7 +275,7 @@ | |
| 14 | LOGGER.info("Loaded {} skill handlers.", SkillHandler.getInstance().size());
| |
| 15 | LOGGER.info("Loaded {} target handlers.", TargetHandler.getInstance().size());
| |
| 16 | LOGGER.info("Loaded {} user command handlers.", UserCommandHandler.getInstance().size());
| |
| 17 | + LOGGER.info("Loaded {} user VoicedCommandHandler handlers.", VoicedCommandHandler.getInstance().size());
| |
| 18 | StringUtil.printSection("System");
| |
| 19 | Runtime.getRuntime().addShutdownHook(Shutdown.getInstance()); | |
| 20 | ||
| 21 | diff --git a/java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java | |
| 22 | new file mode 100644 | |
| 23 | index 0000000..8646215 | |
| 24 | --- /dev/null | |
| 25 | +++ b/java/net/sf/l2j/gameserver/handler/IVoicedCommandHandler.java | |
| 26 | @@ -0,0 +1,25 @@ | |
| 27 | +package net.sf.l2j.gameserver.handler; | |
| 28 | + | |
| 29 | +import net.sf.l2j.gameserver.model.actor.Player; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * This class ... | |
| 33 | + * @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $ | |
| 34 | + */ | |
| 35 | +public interface IVoicedCommandHandler | |
| 36 | +{
| |
| 37 | + /** | |
| 38 | + * this is the worker method that is called when someone uses an admin command. | |
| 39 | + * @param activeChar | |
| 40 | + * @param command | |
| 41 | + * @param target | |
| 42 | + * @return command success | |
| 43 | + */ | |
| 44 | + public boolean useVoicedCommand(String command, Player activeChar, String target); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * this method is called at initialization to register all the item ids automatically | |
| 48 | + * @return all known itemIds | |
| 49 | + */ | |
| 50 | + public String[] getVoicedCommandList(); | |
| 51 | +} | |
| 52 | diff --git a/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java | |
| 53 | new file mode 100644 | |
| 54 | index 0000000..4082f7a | |
| 55 | --- /dev/null | |
| 56 | +++ b/java/net/sf/l2j/gameserver/handler/VoicedCommandHandler.java | |
| 57 | @@ -0,0 +1,65 @@ | |
| 58 | +package net.sf.l2j.gameserver.handler; | |
| 59 | + | |
| 60 | +import java.util.HashMap; | |
| 61 | +import java.util.Map; | |
| 62 | +import java.util.logging.Logger; | |
| 63 | + | |
| 64 | +import net.sf.l2j.gameserver.GameServer; | |
| 65 | + | |
| 66 | +public class VoicedCommandHandler | |
| 67 | +{
| |
| 68 | + private static Logger LOGGER = Logger.getLogger(GameServer.class.getName()); | |
| 69 | + | |
| 70 | + private static VoicedCommandHandler _instance; | |
| 71 | + | |
| 72 | + private final Map<String, IVoicedCommandHandler> _datatable; | |
| 73 | + | |
| 74 | + public static VoicedCommandHandler getInstance() | |
| 75 | + {
| |
| 76 | + if (_instance == null) | |
| 77 | + {
| |
| 78 | + _instance = new VoicedCommandHandler(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + return _instance; | |
| 82 | + } | |
| 83 | + | |
| 84 | + private VoicedCommandHandler() | |
| 85 | + {
| |
| 86 | + _datatable = new HashMap<>(); | |
| 87 | + //registrar comando aqui exemplo abaixo | |
| 88 | + //registerVoicedCommandHandler(new Shiff_Mod()); | |
| 89 | + | |
| 90 | + LOGGER.info("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers.");
| |
| 91 | + } | |
| 92 | + | |
| 93 | + public void registerVoicedCommandHandler(final IVoicedCommandHandler handler) | |
| 94 | + {
| |
| 95 | + String[] ids = handler.getVoicedCommandList(); | |
| 96 | + | |
| 97 | + for (final String id : ids) | |
| 98 | + {
| |
| 99 | + _datatable.put(id, handler); | |
| 100 | + } | |
| 101 | + | |
| 102 | + ids = null; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public IVoicedCommandHandler getVoicedCommandHandler(final String voicedCommand) | |
| 106 | + {
| |
| 107 | + String command = voicedCommand; | |
| 108 | + | |
| 109 | + if (voicedCommand.indexOf(" ") != -1)
| |
| 110 | + {
| |
| 111 | + command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
| |
| 112 | + } | |
| 113 | + return _datatable.get(command); | |
| 114 | + } | |
| 115 | + /** | |
| 116 | + * @return | |
| 117 | + */ | |
| 118 | + public int size() | |
| 119 | + {
| |
| 120 | + return _datatable.size(); | |
| 121 | + } | |
| 122 | +} | |
| 123 | \ No newline at end of file | |
| 124 | diff --git a/java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java b/java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java | |
| 125 | index a707ce5..6c2d0f2 100644 | |
| 126 | --- a/java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java | |
| 127 | +++ b/java/net/sf/l2j/gameserver/handler/chathandlers/ChatAll.java | |
| 128 | @@ -1,8 +1,12 @@ | |
| 129 | package net.sf.l2j.gameserver.handler.chathandlers; | |
| 130 | ||
| 131 | +import java.util.StringTokenizer; | |
| 132 | + | |
| 133 | import net.sf.l2j.gameserver.enums.FloodProtector; | |
| 134 | import net.sf.l2j.gameserver.enums.SayType; | |
| 135 | import net.sf.l2j.gameserver.handler.IChatHandler; | |
| 136 | +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler; | |
| 137 | +import net.sf.l2j.gameserver.handler.VoicedCommandHandler; | |
| 138 | import net.sf.l2j.gameserver.model.actor.Player; | |
| 139 | import net.sf.l2j.gameserver.network.serverpackets.CreatureSay; | |
| 140 | ||
| 141 | @@ -18,12 +22,41 @@ | |
| 142 | {
| |
| 143 | if (!player.getClient().performAction(FloodProtector.GLOBAL_CHAT)) | |
| 144 | return; | |
| 145 | + boolean vcd_used = false; | |
| 146 | + if (text.startsWith("."))
| |
| 147 | + {
| |
| 148 | + StringTokenizer st = new StringTokenizer(text); | |
| 149 | + IVoicedCommandHandler vch; | |
| 150 | + String command = ""; | |
| 151 | + if (st.countTokens() > 1) | |
| 152 | + {
| |
| 153 | + command = st.nextToken().substring(1); | |
| 154 | + target = text.substring(command.length() + 2); | |
| 155 | + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command); | |
| 156 | + } | |
| 157 | + else | |
| 158 | + {
| |
| 159 | + command = text.substring(1); | |
| 160 | + vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command); | |
| 161 | + } | |
| 162 | + | |
| 163 | + if (vch != null) | |
| 164 | + {
| |
| 165 | + vch.useVoicedCommand(command, player, text); | |
| 166 | + vcd_used = true; | |
| 167 | + | |
| 168 | + } | |
| 169 | + } | |
| 170 | ||
| 171 | - final CreatureSay cs = new CreatureSay(player, type, text); | |
| 172 | - for (Player knownPlayer : player.getKnownTypeInRadius(Player.class, 1250)) | |
| 173 | - knownPlayer.sendPacket(cs); | |
| 174 | - | |
| 175 | - player.sendPacket(cs); | |
| 176 | + if (!vcd_used) | |
| 177 | + {
| |
| 178 | + final CreatureSay cs = new CreatureSay(player, type, text); | |
| 179 | + for (Player knownPlayer : player.getKnownTypeInRadius(Player.class, 1250)) | |
| 180 | + knownPlayer.sendPacket(cs); | |
| 181 | + | |
| 182 | + player.sendPacket(cs); | |
| 183 | + | |
| 184 | + } | |
| 185 | } | |
| 186 | ||
| 187 | @Override | |
| 188 | diff --git a/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java b/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java | |
| 189 | index d3a2c47..1b528aa 100644 | |
| 190 | --- a/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java | |
| 191 | +++ b/java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java | |
| 192 | @@ -10,6 +10,8 @@ | |
| 193 | import net.sf.l2j.gameserver.enums.FloodProtector; | |
| 194 | import net.sf.l2j.gameserver.handler.AdminCommandHandler; | |
| 195 | import net.sf.l2j.gameserver.handler.IAdminCommandHandler; | |
| 196 | +import net.sf.l2j.gameserver.handler.IVoicedCommandHandler; | |
| 197 | +import net.sf.l2j.gameserver.handler.VoicedCommandHandler; | |
| 198 | import net.sf.l2j.gameserver.model.World; | |
| 199 | import net.sf.l2j.gameserver.model.WorldObject; | |
| 200 | import net.sf.l2j.gameserver.model.actor.Npc; | |
| 201 | @@ -98,6 +100,21 @@ | |
| 202 | html.disableValidation(); | |
| 203 | player.sendPacket(html); | |
| 204 | } | |
| 205 | + else if (_command.startsWith("voiced_"))
| |
| 206 | + {
| |
| 207 | + String command = _command.split(" ")[0];
| |
| 208 | + | |
| 209 | + IVoicedCommandHandler ach = VoicedCommandHandler.getInstance().getVoicedCommandHandler(_command.substring(7)); | |
| 210 | + | |
| 211 | + if (ach == null) | |
| 212 | + {
| |
| 213 | + player.sendMessage("The command " + command.substring(7) + " does not exist!");
| |
| 214 | + LOGGER.warn("No handler registered for command '" + _command + "'");
| |
| 215 | + return; | |
| 216 | + } | |
| 217 | + | |
| 218 | + ach.useVoicedCommand(_command.substring(7), player, null); | |
| 219 | + } | |
| 220 | else if (_command.startsWith("npc_"))
| |
| 221 | {
| |
| 222 | if (!player.validateBypass(_command)) | |
| 223 |