|
22 | 22 | import org.bukkit.event.EventPriority; |
23 | 23 | import org.bukkit.event.Listener; |
24 | 24 | import org.bukkit.event.player.AsyncPlayerChatEvent; |
25 | | -import org.bukkit.event.player.PlayerCommandPreprocessEvent; |
26 | | -import org.bukkit.event.server.ServerCommandEvent; |
27 | 25 | import org.bukkit.help.HelpMap; |
28 | 26 | import org.bukkit.help.HelpTopic; |
29 | 27 | import org.bukkit.plugin.SimplePluginManager; |
@@ -125,46 +123,6 @@ public static String unescape(String string) { |
125 | 123 | return "" + unescape.matcher(string).replaceAll("$0"); |
126 | 124 | } |
127 | 125 |
|
128 | | - private final static Listener commandListener = new Listener() { |
129 | | - |
130 | | - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
131 | | - public void onPlayerCommand(PlayerCommandPreprocessEvent event) { |
132 | | - // Spigot will simply report that the command doesn't exist if a player does not have permission to use it. |
133 | | - // This is good security but, well, it's a breaking change for Skript. So we need to check for permissions |
134 | | - // ourselves and handle those messages, for every command. |
135 | | - |
136 | | - // parse command, see if it's a skript command |
137 | | - String[] cmd = event.getMessage().substring(1).split("\\s+", 2); |
138 | | - String label = cmd[0].toLowerCase(Locale.ENGLISH); |
139 | | - String arguments = cmd.length == 1 ? "" : "" + cmd[1]; |
140 | | - ScriptCommand command = commands.get(label); |
141 | | - |
142 | | - // is it a skript command? |
143 | | - if (command != null) { |
144 | | - // if so, check permissions to handle ourselves |
145 | | - if (!command.checkPermissions(event.getPlayer(), label, arguments)) |
146 | | - event.setCancelled(true); |
147 | | - |
148 | | - // we can also handle case sensitivity here: |
149 | | - if (SkriptConfig.caseInsensitiveCommands.value()) { |
150 | | - cmd[0] = event.getMessage().charAt(0) + label; |
151 | | - event.setMessage(String.join(" ", cmd)); |
152 | | - } |
153 | | - } |
154 | | - } |
155 | | - |
156 | | - @SuppressWarnings("null") |
157 | | - @EventHandler(priority = EventPriority.HIGHEST) |
158 | | - public void onServerCommand(ServerCommandEvent event) { |
159 | | - if (event.getCommand().isEmpty() || event.isCancelled()) |
160 | | - return; |
161 | | - if ((Skript.testing() || SkriptConfig.enableEffectCommands.value()) && event.getCommand().startsWith(SkriptConfig.effectCommandToken.value())) { |
162 | | - if (handleEffectCommand(event.getSender(), event.getCommand())) |
163 | | - event.setCancelled(true); |
164 | | - } |
165 | | - } |
166 | | - }; |
167 | | - |
168 | 126 | static boolean handleEffectCommand(CommandSender sender, String command) { |
169 | 127 | if (!(Skript.testing() || sender instanceof ConsoleCommandSender || sender.hasPermission("skript.effectcommands") || SkriptConfig.allowOpsToUseEffectCommands.value() && sender.isOp())) |
170 | 128 | return false; |
@@ -279,8 +237,6 @@ public static void unregisterCommand(ScriptCommand scriptCommand) { |
279 | 237 |
|
280 | 238 | public static void registerListeners() { |
281 | 239 | if (!registeredListeners) { |
282 | | - Bukkit.getPluginManager().registerEvents(commandListener, Skript.getInstance()); |
283 | | - |
284 | 240 | Bukkit.getPluginManager().registerEvents(new Listener() { |
285 | 241 | @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) |
286 | 242 | public void onPlayerChat(AsyncPlayerChatEvent event) { |
|
0 commit comments