@EventHandler public void onServerCmd(ServerCommandEvent e){ String[] args = e.getCommand().replace("/", "").split(" "); String msg = null; if (e.getCommand().length() > args[0].length()+1){ msg = e.getCommand().substring(args[0].length()+1); } if (UChat.get().getUCConfig().getTellAliases().contains(args[0])){ if (args.length >= 3){ Player p = UChat.get().getServer().getPlayer(args[1]); if (p == null || !p.isOnline()){ UChat.get().getLang().sendMessage(e.getSender(), "listener.invalidplayer"); return; } msg = msg.substring(args[1].length()+1); UChat.get().tempTellPlayers.put("CONSOLE", p.getName()); UChat.get().command.add("CONSOLE"); sendPreTell(UChat.get().getServer().getConsoleSender(), p, msg); e.setCancelled(true); } } }
@SuppressWarnings("null") @EventHandler(priority = EventPriority.HIGHEST) public void onServerCommand(final ServerCommandEvent e) { if (e.getCommand() == null || e.getCommand().isEmpty()) return; if (SkriptConfig.enableEffectCommands.value() && e.getCommand().startsWith(SkriptConfig.effectCommandToken.value())) { if (handleEffectCommand(e.getSender(), e.getCommand())) { e.setCommand(""); suppressUnknownCommandMessage = true; } return; } if (handleCommand(e.getSender(), e.getCommand())) { e.setCommand(""); suppressUnknownCommandMessage = true; } }
@HookHandler(priority = Priority.CRITICAL) public void onCommand(final ConsoleCommandHook hook) { String command = ""; for (String s : hook.getCommand()) { command += s + " "; } server.getPluginManager().callEvent(new ServerCommandEvent(new CanaryCommandSender(hook.getCaller()), command) { @Override public void setCommand(String msg) { super.setCommand(msg); // Set command } }); if (server.dispatchCommand(new CanaryCommandSender(hook.getCaller()), command)) { hook.setCanceled(); } }
public void aB() { SpigotTimings.serverCommandTimer.startTiming(); // Spigot while (!this.j.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.j.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); this.server.getPluginManager().callEvent(event); servercommand = new ServerCommand(event.getCommand(), servercommand.source); // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand this.server.dispatchServerCommand(this.console, servercommand); // CraftBukkit end } SpigotTimings.serverCommandTimer.stopTiming(); // Spigot }
@EventHandler(priority = EventPriority.MONITOR) public void onAction(ServerCommandEvent e) { boolean isAction = false; String commandUsed = ""; for (String start : Config.actionAliases) { start = start.substring(1); if (!e.getCommand().startsWith(start)) continue; commandUsed = start; isAction = true; break; } if (!isAction) return; String message = Config.btiAction; message = message.replace("{name}", e.getSender().getName()); message = message.replace("{message}", e.getCommand().substring(commandUsed.length())); plugin.bh.sendMessage(message); }
@EventHandler(priority = EventPriority.MONITOR) public void onSay(ServerCommandEvent e) { boolean isAction = false; String commandUsed = ""; for (String start : Config.sayAliases) { start = start.substring(1); if (!e.getCommand().startsWith(start)) continue; commandUsed = start; isAction = true; break; } if (!isAction) return; String message = Config.btiSay; message = message.replace("{name}", e.getSender().getName()); message = message.replace("{message}", e.getCommand().substring(commandUsed.length())); plugin.bh.sendMessage(message); }
public void aL() { SpigotTimings.serverCommandTimer.startTiming(); // Spigot while (!this.serverCommandQueue.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command); server.getPluginManager().callEvent(event); if (event.isCancelled()) continue; servercommand = new ServerCommand(event.getCommand(), servercommand.source); // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand server.dispatchServerCommand(console, servercommand); // CraftBukkit end } SpigotTimings.serverCommandTimer.stopTiming(); // Spigot }
@EventHandler public final void onCommand(ServerCommandEvent e) { String[] array = e.getCommand().split(" "); String[] args = new String[array.length-1]; for(int i = 0; i < args.length; i++) { args[i] = array[i+1]; } String cmd = array[0].replaceFirst("/", ""); if(commands.containsKey(cmd.toLowerCase())) { commands.get(cmd.toLowerCase()).execute(e.getSender(), cmd, args); e.setCommand("emptycommand"); } }
@EventHandler(priority = EventPriority.MONITOR) public void onServerCommand (ServerCommandEvent event) { String command = event.getCommand().toLowerCase(); if (command.equals("/p reload") || command.equals("/bp reload") || command.equals("/perm reload") || command.equals("/permissions reload")) { final CommandSender sender = event.getSender(); plugin.getServer().getScheduler() .scheduleSyncDelayedTask(plugin, new Runnable() { public void run () { plugin.refreshCache(sender); } }, 1L); return; } }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onServerCommand(ServerCommandEvent evt) { evt.setCancelled(handleCommand(evt.getSender(), CommandType.SLASH, CommandType.SLASH.getPrefix() + evt.getCommand()) // Handle console commands. || handleCommand(evt.getSender(), CommandType.COMMAND_BLOCK, evt.getCommand())); // Command Block commands. if (evt.getCommand().startsWith("/ ")) { sendStaffChat(evt.getSender(), evt.getCommand().substring(2)); evt.setCancelled(true); } }
@EventHandler public void onCommand(ServerCommandEvent event) { String msg = "/" + event.getCommand(); CommandSender sender = event.getSender(); this.handle(msg, sender, event); }
@EventHandler(priority = EventPriority.MONITOR) public void processCommands(ServerCommandEvent evt) { if (evt.isCancelled() || evt.isAsynchronous()) return; Command cmd = CommandFactory.commands.get(evt.getCommand()); if (cmd == null || cmd instanceof PlayerOnly) return; cmd.run(evt.getSender()); }
@EventHandler(priority = EventPriority.NORMAL) public void onBroadcastCommand(ServerCommandEvent event) { String cmd = ChatColor.stripColor(event.getCommand()); if (cmd.equals("broadcast ") || cmd.equals("bc ")) { String msg = cmd.split(" ", 2)[1]; messenger.sendMessageToAllBoundChannel("\uD83D\uDCE2 " + msg); boolean seeBc = configsManager.getModChannelConfig().getBoolean("See_Broadcast"); if(seeBc) { messenger.sendMessageToAllModChannel("\uD83D\uDCE2 " + msg ); } } }
@EventHandler(priority = EventPriority.LOWEST) public void on(ServerCommandEvent event) { String command = event.getCommand(); if (intercept(event.getSender(), command, event)) { event.setCommand(collapse(command)); } }
@SuppressWarnings("unchecked") @Override public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) { what = matchedPattern; if (!ScriptLoader.isCurrentEvent(PlayerCommandPreprocessEvent.class, ServerCommandEvent.class)) { if (what != ARGS) // ExprArgument has the same syntax Skript.error("The 'command' expression can only be used in a command event"); return false; } return true; }
@SuppressWarnings("null") @Override public boolean check(final Event e) { if (command == null) return true; final String message; if (e instanceof PlayerCommandPreprocessEvent) { assert ((PlayerCommandPreprocessEvent) e).getMessage().startsWith("/"); message = ((PlayerCommandPreprocessEvent) e).getMessage().substring(1); } else { message = ((ServerCommandEvent) e).getCommand(); } return StringUtils.startsWithIgnoreCase(message, command) && (command.contains(" ") || message.length() == command.length() || Character.isWhitespace(message.charAt(command.length()))); // if only the command is given, match that command only }
public boolean canPass(ServerCommandEvent e){ Player p = (Player) e.getSender(); try { String[] split = e.getCommand().split(" "); String command = split[0].substring(1, split[0].length()); for (String s : accept) { if (s.equals("*")) return true; String arg = s.substring(2, s.length()); switch (s.substring(0, 1)) { case "r": return arg.equalsIgnoreCase(PermissionHandler.getGroupName(p)); case "p": return arg.equalsIgnoreCase(p.getName()); case "c": return arg.equalsIgnoreCase(command); case "a": for (int i = 1; i < split.length; i++) { if (arg.equalsIgnoreCase(split[i])) return true; } } } return false; } catch (Exception ex) { return false; } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void on(ServerCommandEvent e) { if(e.isCancelled()) { return; } if(processCommand(e.getSender(), getParameters(e.getCommand()))) { e.setCancelled(true); } }
public void aB() { while (!this.j.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.j.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); this.server.getPluginManager().callEvent(event); servercommand = new ServerCommand(event.getCommand(), servercommand.source); // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand this.server.dispatchServerCommand(this.console, servercommand); // CraftBukkit end } }
@EventHandler(priority = EventPriority.LOWEST) public void onServerCommandEvent(ServerCommandEvent event) { String command = event.getCommand(); boolean restart = command.startsWith("restart"); if (restart || command.startsWith("stop")) { ServerShutdown.this.run(restart); event.setCommand(""); // dont execute stop! } }
@EventHandler public void onCmd(ServerCommandEvent e) { String cmd = e.getCommand(); String replacement = PlaceholderHandler.replacePlaceholders(e.getSender() instanceof Player ? (Player) e.getSender() : null, cmd); if (replacement != null && !cmd.equals(replacement)) { e.setCommand(cmd); } }
public void as() { while (!this.l.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.l.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); this.server.getPluginManager().callEvent(event); servercommand = new ServerCommand(event.getCommand(), servercommand.source); // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand this.server.dispatchServerCommand(this.console, servercommand); // CraftBukkit end } }
@EventHandler public void onCommand(ServerCommandEvent event) { if (event.getCommand().equalsIgnoreCase("/reload") || event.getCommand().equalsIgnoreCase("reload")) { event.setCommand(""); event.getSender().sendMessage("PlotMe disabled /reload to prevent errors from occuring."); } }
@EventHandler public void onCommand(ServerCommandEvent e) { Console console = Necessities.getConsole(); if (console.chatToggled() && !e.getCommand().equalsIgnoreCase("togglechat") && !e.getCommand().equalsIgnoreCase("tc")) e.setCommand("say " + e.getCommand()); e.setCommand(ChatColor.translateAlternateColorCodes('&', e.getCommand())); Necessities.getSpy().broadcast(console.getName().replaceAll(":", "") + ChatColor.AQUA, e.getCommand()); Necessities.getBot().logConsole(e.getCommand()); if (e.getCommand().startsWith("tps")) e.setCommand("necessities:" + e.getCommand()); }
@Deprecated // Moved to TFM_TelnetListener @EventHandler(priority = EventPriority.NORMAL) public void onServerCommand(ServerCommandEvent event) { if (TFM_CommandBlocker.getInstance().isCommandBlocked(event.getCommand(), event.getSender())) { event.setCommand(""); } }
@EventHandler public void onServerStop(ServerCommandEvent event){ if(event.getCommand().equals("stop")){ for(Player player : Bukkit.getOnlinePlayers()) player.kickPlayer("Server closed."); for(World world : Bukkit.getWorlds()){ for(Map map : Map.getMaps()){ if(world.getName().startsWith(map.getName())){ Bukkit.unloadWorld(world, true); FileUtils.delete(world.getWorldFolder()); } } } } }
public void am() { while (!this.k.isEmpty()) { ServerCommand servercommand = (ServerCommand) this.k.remove(0); // CraftBukkit start - ServerCommand for preprocessing ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command); this.server.getPluginManager().callEvent(event); servercommand = new ServerCommand(event.getCommand(), servercommand.source); // this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand this.server.dispatchServerCommand(this.console, servercommand); // CraftBukkit end } }
@EventHandler public void onConsoleCommand(ServerCommandEvent e) { commandEvent.checkServerReload(e); }
public void checkServerReload(ServerCommandEvent e) { if (e.getCommand().startsWith("rl") || e.getCommand().startsWith("reload")) { Core.setReloading(true); } return; }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onCommand(ServerCommandEvent event) { event.setCommand(attemptRebind(event.getCommand())); }
@EventHandler public void onServerCommand(ServerCommandEvent e) { handleCommand(e.getSender(), e.getCommand().toLowerCase(), e); }
@EventHandler(priority = EventPriority.LOWEST) public void consoleStopEvent(ServerCommandEvent event) { if (event.getCommand().equals("stop") || event.getCommand().equals("/stop")) { forcePlayerSave(); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onConsoleCommand(ServerCommandEvent event) { if (onCommandPreprocess(event.getSender(), event.getCommand())) event.setCommand("dontrunthiscmd"); }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onConsoleCommand(final ServerCommandEvent event) { Check.notNull(event, "The event must not be null!"); this.handleCommandEvent(event.getSender(), event.getCommand(), event); }
@EventHandler public void onServerCommand(ServerCommandEvent event) { String[] msg = event.getCommand().split("\\s+"); if (Bukkit.getPluginManager().isPluginEnabled("dynmap") && msg.length > 1 && msg[0].equalsIgnoreCase("say")) ((DynmapCommonAPI) Bukkit.getPluginManager().getPlugin("dynmap")).sendBroadcastToWeb("Server", Joiner.on(' ').join(Arrays.copyOfRange(msg, 1, msg.length))); }