Java 类org.bukkit.event.server.ServerCommandEvent 实例源码

项目:UltimateChat    文件:UCListener.java   
@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);               
        }
    }       
}
项目:Skript    文件:Commands.java   
@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;
    }
}
项目:CanaryBukkit    文件:CanaryServerListener.java   
@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();
    }
}
项目:Tweakkit-Server    文件:DedicatedServer.java   
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
}
项目:RoyalIRC    文件:BServerListener.java   
@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);
}
项目:RoyalIRC    文件:BServerListener.java   
@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);
}
项目:SpigotSource    文件:DedicatedServer.java   
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
}
项目:xEssentials-deprecated-bukkit    文件:MinigamePlugin.java   
@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");
    }
}
项目:SimpleChat    文件:ServerListener.java   
@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;
      }
  }
项目:Kineticraft    文件:Commands.java   
@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);
    }
}
项目:RCameraStudio    文件:BukkitCommandManager.java   
@EventHandler
public void onCommand(ServerCommandEvent event) {
    String msg = "/" + event.getCommand();
    CommandSender sender = event.getSender();

    this.handle(msg, sender, event);
}
项目:Recreator    文件:Recreator.java   
@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());
}
项目:Minecordbot    文件:BroadcastCommandListener.java   
@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 );
        }
    }
}
项目:OpGuard    文件:CommandInterceptor.java   
@EventHandler(priority = EventPriority.LOWEST)
public void on(ServerCommandEvent event)
{
    String command = event.getCommand();

    if (intercept(event.getSender(), command, event))
    {
        event.setCommand(collapse(command));
    }
}
项目:Skript    文件:ExprCommand.java   
@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;
}
项目:Skript    文件:EvtCommand.java   
@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
}
项目:iZenith-PVP    文件:CommandFilter.java   
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;
    }
}
项目:Phantom    文件:CommandSVC.java   
@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);
    }
}
项目:CraftBukkit    文件:DedicatedServer.java   
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
    }
}
项目:SupaCommons    文件:ServerShutdown.java   
@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!
  }
}
项目:IZenith-Main    文件:CommandFilter.java   
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;
    }
}
项目:uSkyBlock    文件:ServerCommandPlaceholder.java   
@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);
    }
}
项目:Almura-Server    文件:DedicatedServer.java   
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
    }
}
项目:PlotMe-Core    文件:BukkitPlotListener.java   
@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.");
    }
}
项目:Necessities    文件:Listeners.java   
@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());
}
项目:TatsuCraftMod    文件:TFM_ServerListener.java   
@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("");
    }
}
项目:TCMinigames    文件:CommandListener.java   
@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());
                }
            }
        }
    }
}
项目:Craft-city    文件:DedicatedServer.java   
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
    }
}
项目:EssentialCommands    文件:CoreListener.java   
@EventHandler
public void onConsoleCommand(ServerCommandEvent e) {
    commandEvent.checkServerReload(e);
}
项目:EssentialCommands    文件:CommandEvent.java   
public void checkServerReload(ServerCommandEvent e) {
    if (e.getCommand().startsWith("rl") || e.getCommand().startsWith("reload")) {
        Core.setReloading(true);
    }
    return;
}
项目:factions-top    文件:CommandListener.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCommand(ServerCommandEvent event) {
    event.setCommand(attemptRebind(event.getCommand()));
}
项目:LuckPerms    文件:BukkitPlatformListener.java   
@EventHandler
public void onServerCommand(ServerCommandEvent e) {
    handleCommand(e.getSender(), e.getCommand().toLowerCase(), e);
}
项目:BetterShards    文件:BetterShardsListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void consoleStopEvent(ServerCommandEvent event) {
    if (event.getCommand().equals("stop") || event.getCommand().equals("/stop")) {
        forcePlayerSave();
    }
}
项目:ButtonChat    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsoleCommand(ServerCommandEvent event) {
    if (onCommandPreprocess(event.getSender(), event.getCommand()))
        event.setCommand("dontrunthiscmd");
}
项目:CraftoPlugin    文件:CraftoCommands.java   
@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);
}
项目:FixChat    文件:FixChat.java   
@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)));
}