Java 类org.bukkit.command.CommandExecutor 实例源码

项目:helper    文件:CommandMapUtil.java   
/**
 * Registers a CommandExecutor with the server
 *
 * @param plugin the plugin instance
 * @param command the command instance
 * @param aliases the command aliases
 * @param <T> the command executor class type
 * @return the command executor
 */
@Nonnull
public static <T extends CommandExecutor> T registerCommand(@Nonnull Plugin plugin, @Nonnull T command, @Nonnull String... aliases) {
    Preconditions.checkArgument(aliases.length != 0, "No aliases");
    for (String alias : aliases) {
        try {
            PluginCommand cmd = COMMAND_CONSTRUCTOR.newInstance(alias, plugin);

            getCommandMap().register(plugin.getDescription().getName(), cmd);
            getKnownCommandMap().put(plugin.getDescription().getName().toLowerCase() + ":" + alias.toLowerCase(), cmd);
            getKnownCommandMap().put(alias.toLowerCase(), cmd);
            cmd.setLabel(alias.toLowerCase());

            cmd.setExecutor(command);
            if (command instanceof TabCompleter) {
                cmd.setTabCompleter((TabCompleter) command);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return command;
}
项目:helper    文件:CommandMapUtil.java   
/**
 * Unregisters a CommandExecutor with the server
 *
 * @param command the command instance
 * @param <T> the command executor class type
 * @return the command executor
 */
@Nonnull
public static <T extends CommandExecutor> T unregisterCommand(@Nonnull T command) {
    CommandMap map = getCommandMap();
    try {
        //noinspection unchecked
        Map<String, Command> knownCommands = (Map<String, Command>) KNOWN_COMMANDS_FIELD.get(map);

        Iterator<Command> iterator = knownCommands.values().iterator();
        while (iterator.hasNext()) {
            Command cmd = iterator.next();
            if (cmd instanceof PluginCommand) {
                CommandExecutor executor = ((PluginCommand) cmd).getExecutor();
                if (command == executor) {
                    cmd.unregister(map);
                    iterator.remove();
                }
            }
        }
    } catch (Exception e) {
        throw new RuntimeException("Could not unregister command", e);
    }

    return command;
}
项目:EscapeLag    文件:CommandInjector.java   
/**
 * 
 * @author jiongjionger,Vlvxingze
 */

public static void inject(Plugin plg) {
    if (plg != null) {
        try {
            SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
            for (Command command : simpleCommandMap.getCommands()) {
                if (command instanceof PluginCommand) {
                    PluginCommand pluginCommand = (PluginCommand) command;
                    if (plg.equals(pluginCommand.getPlugin())) {
                        FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
                        FieldAccessor<TabCompleter> tabField = Reflection.getField(PluginCommand.class, "completer", TabCompleter.class);
                        CommandInjector commandInjector = new CommandInjector(plg, commandField.get(pluginCommand), tabField.get(pluginCommand));
                        commandField.set(pluginCommand, commandInjector);
                        tabField.set(pluginCommand, commandInjector);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:EscapeLag    文件:CommandInjector.java   
public static void uninject(Plugin plg) {
    if (plg != null) {
        try {
            SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
            for (Command command : simpleCommandMap.getCommands()) {
                if (command instanceof PluginCommand) {
                    PluginCommand pluginCommand = (PluginCommand) command;
                    if (plg.equals(pluginCommand.getPlugin())) {
                        FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
                        FieldAccessor<TabCompleter> tabField = Reflection.getField(PluginCommand.class, "completer", TabCompleter.class);
                        CommandExecutor executor = commandField.get(pluginCommand);
                        if (executor instanceof CommandInjector) {
                            commandField.set(pluginCommand, ((CommandInjector) executor).getCommandExecutor());
                        }
                        TabCompleter completer = tabField.get(pluginCommand);
                        if (completer instanceof CommandInjector) {
                            tabField.set(pluginCommand, ((CommandInjector) executor).getTabCompleter());
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:NeverLag    文件:MonitorUtils.java   
public static Map<String, MonitorRecord> getCommandTimingsByPlugin(Plugin plg) {
    Map<String, MonitorRecord> record = new HashMap<>();
    if (plg == null) {
        return record;
    }
    try {
        SimpleCommandMap simpleCommandMap = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(Bukkit.getPluginManager());
        for (Command command : simpleCommandMap.getCommands()) {
            if (command instanceof PluginCommand) {
                PluginCommand pluginCommand = (PluginCommand) command;
                if (plg.equals(pluginCommand.getPlugin())) {
                    FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class, "executor", CommandExecutor.class);
                    CommandExecutor executor = commandField.get(pluginCommand);
                    if (executor instanceof CommandInjector) {
                        CommandInjector commandInjector = (CommandInjector) executor;
                        record = mergeRecordMap(record, commandInjector.getMonitorRecordMap());
                    }

                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return record;
}
项目:BukkitPluginDevelopment    文件:Command.java   
@Override
public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
    if (0 < args.length) { // 引数がある
        // 1つめの引数(args[0])を小文字に変換する(/hoge fugaでも/hoge FUGAでも実行出来る様に)
        String subCommand = args[0].toLowerCase(Locale.ENGLISH);
        // そのサブコマンドに対応したExecutorを取得する
        CommandExecutor executor = sub.get(subCommand);

        // 非null == サブコマンドが登録されていたなら実行する
        // containsKeyでチェックする必要はない(HashMapのcontainsKey自体がgetして非nullならtrue、みたいな実装になっている)
        if (command != null) {
            // 実行して終了する
            return executor.onCommand(sender, command, label, args);
        }
    }

    // ここまで来た==サブコマンドがなかったか、登録されていなかった時は
    // 引数がない時の処理(helpを表示)を実行する
    return sub.get(NO_ARGS).onCommand(sender, command, label, args);
}
项目:flyingblocksapi    文件:ExamplesCommandExecutor.java   
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 1) {
        return false;
    }

    String example = args[0];
    CommandExecutor executor;

    if (example.equalsIgnoreCase("flag")) {
        executor = new FlagCommandExecutor();
    } else if (example.equalsIgnoreCase("rising")) {
        executor = new RisingBlockCommandExecutor();
    } else if (example.equalsIgnoreCase("static")) {
        executor = new StaticBlockCommandExecutor();
    } else if (example.equalsIgnoreCase("sinewave")) {
        executor = new SineWaveBlockCommandExecutor();
    } else {
        return false;
    }

    String[] newargs = Arrays.copyOfRange(args, 1, args.length);
    return executor.onCommand(sender, command, label, newargs);

}
项目:Zeus    文件:Zeus.java   
@Override
public void onDisable() {
    getCommand("zeus").setExecutor((CommandExecutor)null);
    getCommand("autosave").setExecutor((CommandExecutor)null);
    getCommand("jailtime").setExecutor((CommandExecutor)null);
    getCommand("jail").setExecutor((CommandExecutor)null);
    getCommand("invite").setExecutor((CommandExecutor)null);
    getCommand("goto").setExecutor((CommandExecutor)null);
    getCommand("tactical").setExecutor((CommandExecutor)null);
    if (this.WorldEditExists)
        getCommand("regionedit").setExecutor((CommandExecutor)null);

    this.getServer().getScheduler().cancelTask(this.jailID);

    this.getConfig().set("Autosave.enabled", this.autosaveActive);
    this.getConfig().set("Autosave.time", this.autosaveTime);
    jailMan.saveDATA();
    tactical.saveDATA();
    checkMan.saveDATA();
    this.saveConfig();
    getLogger().info("Zeus Data Saved!");
}
项目:EscapeLag    文件:MonitorUtils.java   
public static Map<String, MonitorRecord> getCommandTimingsByPlugin(Plugin plg) {
    Map<String, MonitorRecord> record = new HashMap<>();
    if (plg == null) {
        return record;
    }
    try {
        SimpleCommandMap simpleCommandMap = Reflection
                .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class)
                .get(Bukkit.getPluginManager());
        for (Command command : simpleCommandMap.getCommands()) {
            if (command instanceof PluginCommand) {
                PluginCommand pluginCommand = (PluginCommand) command;
                if (plg.equals(pluginCommand.getPlugin())) {
                    FieldAccessor<CommandExecutor> commandField = Reflection.getField(PluginCommand.class,
                            "executor", CommandExecutor.class);
                    CommandExecutor executor = commandField.get(pluginCommand);
                    if (executor instanceof CommandInjector) {
                        CommandInjector commandInjector = (CommandInjector) executor;
                        record = mergeRecordMap(record, commandInjector.getMonitorRecordMap());
                    }

                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return record;
}
项目:Mob-AI    文件:Main.java   
public void onEnable() {
    PluginDescriptionFile pdfFile = this.getDescription();
    this.logger.info(String.valueOf(String.valueOf(pdfFile.getName())) + " Version: " + pdfFile.getVersion() + " by NullDev [EpticMC] has been enabled!");
    this.generateFiles();
    instance = this;

    String[] cmd = {"mob", "mobai"};
    for (int i = 0; i < cmd.length; i++) this.getCommand(cmd[i]).setExecutor((CommandExecutor) new CommandHandler(this));
}
项目:mczone    文件:HiveCommandExecutor.java   
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    CommandExecutor command = null;
    for (Entry<String, CommandExecutor> e : commands.entrySet()) {

        if (e.getKey().equalsIgnoreCase(cmd.getName())) {
            command = e.getValue();

            if (e.getValue() instanceof Permissible) {
                Permissible perm = (Permissible) e.getValue();
                if (perm.hasPermission(Gamer.get(sender))) {
                    command = e.getValue();
                    break;
                }
                else {
                    Chat.player(sender, "&cYou do not have permission to use that command.");
                    return true;
                }
            }
            else {
                command = e.getValue();
                break;
            }
        }
    }

    if (command == null) {
        return false;
    }

    return command.onCommand(sender, cmd, label, args);
}
项目:pl    文件:JPl.java   
@SuppressWarnings("unchecked")
private void loadCommands() {
    InputStream resource = getResource("META-INF/.pl.commands.yml");
    if (resource == null)
        return;

    yamlParser.parse(resource, CommandsFile.class).blockingGet().getCommands().forEach((command, handler) -> {
        PluginCommand bukkitCmd = getCommand(command);
        if (bukkitCmd == null)
            throw new IllegalStateException("could not find command '" + command + "' for plugin...");

        Class<?> handlerType;
        try {
            handlerType = Class.forName(handler.handler);
        } catch (ClassNotFoundException e) {
            throw new IllegalStateException("could not find class " + handler + " for command " + command + "!", e);
        }

        if (!JCmd.class.isAssignableFrom(handlerType)) {
            if (!CommandExecutor.class.isAssignableFrom(handlerType))
                throw new IllegalStateException(handlerType.getName() + " is not a valid handler class, does not extend JCmd");

            CommandExecutor instance = (CommandExecutor) injector.get().getInstance(handlerType);
            bukkitCmd.setExecutor(instance);
            if (instance instanceof TabCompleter)
                bukkitCmd.setTabCompleter((TabCompleter) instance);

        } else {
            Class<? extends JCmd> commandType = (Class<? extends JCmd>) handlerType;

            JCommandExecutor executor = new JCommandExecutor(commandType, injector);

            bukkitCmd.setExecutor(executor);
            bukkitCmd.setTabCompleter(executor);
        }

        getLogger().info("loaded command /" + command + " => " + handlerType.getSimpleName());
    });
}
项目:Chambers    文件:BukkitCommand.java   
/**
 * A slimmed down PluginCommand
 * 
 * @param name
 * @param owner
 */
protected BukkitCommand(String label, CommandExecutor executor, Plugin owner) {
    super(label);
    this.executor = executor;
    this.owningPlugin = owner;
    this.usageMessage = "";
}
项目:Bukkit-Utilities    文件:TestCommand.java   
@Override
public CommandExecutor getExecutor() {
  return (commandSender, command, s, strings) -> {
    commandSender.sendMessage("command is working ~~");
    return true;
  };
}
项目:Bukkit-Utilities    文件:TestCommand2.java   
@Override
public CommandExecutor getExecutor() {
  return ((commandSender, command, s, strings) -> {
    commandSender.sendMessage("test2");
    return true;
  });
}
项目:DragonEggDrop    文件:DragonEggDrop.java   
private void registerCommand(String command, CommandExecutor executor, TabCompleter tabCompleter) {
    if (tabCompleter == null && !(executor instanceof TabCompleter))
        throw new UnsupportedOperationException();

    PluginCommand commandObject = this.getCommand(command);
    if (commandObject == null) return;

    commandObject.setExecutor(executor);
    commandObject.setTabCompleter(tabCompleter != null ? tabCompleter : (TabCompleter) executor);
}
项目:AudioConnect    文件:CommandHandler.java   
public CommandHandler(AudioConnect plugin, Messenger messenger, int commandCooldown) {
    super(plugin, messenger, commandCooldown);
    this.plugin = plugin;

    registerConverter(AudioTrack.class, new FlagArgumentConverter<>(new AudioTrackFlag()));
    registerConverter(AudioDelay.class, new FlagArgumentConverter<>(new AudioDelayFlag()));

    registerCommand(ConnectCommand.class);
    registerCommand(ListCommand.class);
    registerCommand(SendCommand.class);
    registerCommand(RegionCommand.class);
    registerCommand(ReloadCommand.class);
    registerCommand(RegisterCommand.class);
    registerCommand(VerifyCommand.class);
    registerCommand(ImportCommand.class);

    registerCommand(new MuteCommand());
    registerCommand(new UnmuteCommand());

    CommandExecutor aliasExecutor = new AliasCommandExecutor();
    audioCommand = plugin.getCommand("audio");
    audioCommand.setExecutor(aliasExecutor);

    muteCommand = plugin.getCommand("mute");
    muteCommand.setExecutor(aliasExecutor);

    unmuteCommand = plugin.getCommand("unmute");
    unmuteCommand.setExecutor(aliasExecutor);
}
项目:Commons    文件:CommandWrapper.java   
/**
 * @param label    The label of this command
 * @param executor The executor to execute this command
 * @param plugin   The plugin that is providing this command
 */
CommandWrapper( String label, CommandExecutor executor, Plugin plugin ) {
    super( label );
    checkNotNull( executor );
    checkNotNull( plugin );

    this.executor = executor;
    this.plugin = plugin;
    this.usageMessage = "";
}
项目:LagMonitor    文件:CommandInjector.java   
public static void inject(Plugin toInjectPlugin) {
        PluginManager pluginManager = Bukkit.getPluginManager();
        SimpleCommandMap commandMap = Reflection
                .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
        for (Command command : commandMap.getCommands()) {
            if (command instanceof PluginCommand) {
                PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
                Plugin plugin = pluginCommand.getPlugin();
                if (plugin.equals(toInjectPlugin)) {
                    FieldAccessor<CommandExecutor> executorField = Reflection
                            .getField(PluginCommand.class, "executor", CommandExecutor.class);
                    FieldAccessor<TabCompleter> completerField = Reflection
                            .getField(PluginCommand.class, "completer", TabCompleter.class);

                    CommandExecutor executor = executorField.get(pluginCommand);
                    TabCompleter completer = completerField.get(pluginCommand);

                    CommandInjector commandInjector = new CommandInjector(executor, completer);

                    executorField.set(pluginCommand, commandInjector);
                    completerField.set(pluginCommand, commandInjector);
                }
            }

            //idea: inject also vanilla commands?
//            if (command instanceof VanillaCommand) {
//
//            }
        }
    }
项目:LagMonitor    文件:CommandInjector.java   
public static void uninject(Plugin toUninject) {
    PluginManager pluginManager = Bukkit.getPluginManager();
    SimpleCommandMap commandMap = Reflection
            .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
    for (Command command : commandMap.getCommands()) {
        if (command instanceof PluginCommand) {
            PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
            Plugin plugin = pluginCommand.getPlugin();
            if (plugin.equals(toUninject)) {
                FieldAccessor<CommandExecutor> executorField = Reflection
                        .getField(PluginCommand.class, "executor", CommandExecutor.class);
                FieldAccessor<TabCompleter> completerField = Reflection
                        .getField(PluginCommand.class, "completer", TabCompleter.class);

                CommandExecutor executor = executorField.get(pluginCommand);
                if (executor instanceof CommandInjector) {
                    executorField.set(pluginCommand, ((CommandInjector) executor).originalExecutor);
                }

                TabCompleter completer = completerField.get(pluginCommand);
                if (completer instanceof CommandInjector) {
                    completerField.set(pluginCommand, ((CommandInjector) completer).originalCompleter);
                }
            }
        }
    }
}
项目:Devathlon    文件:GameCommand.java   
public GameCommand( String command,
                    boolean consoleable,
                    com.github.vizrtdev.witchhunter.interfaces.CommandExecutor commandExecutor) {
    this.command = command;
    this.consoleable = consoleable;
    this.commandExecutor = commandExecutor;
    WitchHunter.getInstance().getCommand( command ).setExecutor( this );
}
项目:Devathlon    文件:GameCommand.java   
public GameCommand( String command,
                    com.github.vizrtdev.witchhunter.interfaces.CommandExecutor commandExecutor) {
    this.command = command;
    this.consoleable = false;
    this.commandExecutor = commandExecutor;
    WitchHunter.getInstance().getCommand( command ).setExecutor( this );
}
项目:RpgPlus    文件:PluginComponentBase.java   
/**
 * Registers an executor for a command. The command must be declared in the plugin.yml in order to work.
 *
 * @param command  command to register
 * @param executor executor for that command
 */
public final void registerCommand(String command, CommandExecutor executor) {
    PluginCommand cmd = plugin.getCommand(command);
    if (cmd != null) {
        cmd.setExecutor(executor);
    } else {
        getLogger().warning("Command '" + command + "' is not declared in the plugin.yml so it is not available.");
    }
}
项目:WhiteEggCore    文件:CommandFactory.java   
/**
 * コマンド登録メソッド
 *
 * @param pluginInstance  プラグイン
 * @param prefix          prefix
 * @param commandName     コマンド名
 * @param aliases         コマンドの他の名前
 * @param using           コマンドの使用方法
 * @param description     コマンドの説明文
 * @param permission      コマンドの権限
 * @param commandExecutor コマンドの実行クラスのインスタンス
 * @param tabInstance     タブ補間のインスタンス
 */
public static void newCommand(Plugin pluginInstance, String prefix, String commandName, List<String> aliases, String using, String description, String permission, CommandExecutor commandExecutor, TabCompleter tabInstance) {
    CommandFactory factory = new CommandFactory(pluginInstance, commandName);
    factory.setAliases((aliases == null ? new ArrayList<>(0) : aliases));
    factory.setDescription((description == null ? "" : description));
    factory.setUsage((using == null ? "" : using));
    factory.setPermission((permission == null ? "" : permission));
    if (commandExecutor != null) {
        factory.setExecutor(commandExecutor);
    }
    if (tabInstance != null) {
        factory.setTabCompleter(tabInstance);
    }
    factory.register();
}
项目:Zephyr    文件:BukkitCommandHandler.java   
/**
 * A slimmed down PluginCommand
 * 
 * @param name
 * @param owner
 */
protected BukkitCommandWrapper(String label, CommandExecutor executor, Plugin owner) {
    super(label);
    this.executor = executor;
    this.owningPlugin = owner;
    this.usageMessage = "";
}
项目:Gringotts-    文件:Gringotts.java   
private void registerCommands() {
    CommandExecutor playerCommands = gcommand.new Money();
    CommandExecutor moneyAdminCommands = gcommand.new Moneyadmin();
    CommandExecutor adminCommands = gcommand.new GringottsCmd();

    getCommand("balance").setExecutor(playerCommands);
    getCommand("money").setExecutor(playerCommands);
    getCommand("moneyadmin").setExecutor(moneyAdminCommands);
    getCommand("gringotts").setExecutor(adminCommands);
}
项目:gFeatures    文件:RegisterCommand.java   
public void register(CommandExecutor executor, String cmdname){
 try{
        if(Bukkit.getServer() instanceof CraftServer){
            final Field f = CraftServer.class.getDeclaredField("commandMap");
            f.setAccessible(true);
            cmap = (CommandMap)f.get(Bukkit.getServer());
        }
    } catch (Exception e){
        e.printStackTrace();
    }
 gCommand gc = new gCommand(cmdname);
    cmap.register("", gc);
    gc.setExecutor(executor);
}
项目:LagMonitor    文件:CommandInjector.java   
public static void inject(Plugin toInjectPlugin) {
        PluginManager pluginManager = Bukkit.getPluginManager();
        SimpleCommandMap commandMap = Reflection
                .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
        for (Command command : commandMap.getCommands()) {
            if (command instanceof PluginCommand) {
                PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
                Plugin plugin = pluginCommand.getPlugin();
                if (plugin.equals(toInjectPlugin)) {
                    FieldAccessor<CommandExecutor> executorField = Reflection
                            .getField(PluginCommand.class, "executor", CommandExecutor.class);
                    FieldAccessor<TabCompleter> completerField = Reflection
                            .getField(PluginCommand.class, "completer", TabCompleter.class);

                    CommandExecutor executor = executorField.get(pluginCommand);
                    TabCompleter completer = completerField.get(pluginCommand);

                    CommandInjector commandInjector = new CommandInjector(executor, completer);

                    executorField.set(pluginCommand, commandInjector);
                    completerField.set(pluginCommand, commandInjector);
                }
            }

            //idea: inject also vanilla commands?
//            if (command instanceof VanillaCommand) {
//
//            }
        }
    }
项目:LagMonitor    文件:CommandInjector.java   
public static void uninject(Plugin toUninject) {
    PluginManager pluginManager = Bukkit.getPluginManager();
    SimpleCommandMap commandMap = Reflection
            .getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class).get(pluginManager);
    for (Command command : commandMap.getCommands()) {
        if (command instanceof PluginCommand) {
            PluginIdentifiableCommand pluginCommand = (PluginIdentifiableCommand) command;
            Plugin plugin = pluginCommand.getPlugin();
            if (plugin.equals(toUninject)) {
                FieldAccessor<CommandExecutor> executorField = Reflection
                        .getField(PluginCommand.class, "executor", CommandExecutor.class);
                FieldAccessor<TabCompleter> completerField = Reflection
                        .getField(PluginCommand.class, "completer", TabCompleter.class);

                CommandExecutor executor = executorField.get(pluginCommand);
                if (executor instanceof CommandInjector) {
                    executorField.set(pluginCommand, ((CommandInjector) executor).originalExecutor);
                }

                TabCompleter completer = completerField.get(pluginCommand);
                if (completer instanceof CommandInjector) {
                    completerField.set(pluginCommand, ((CommandInjector) completer).originalCompleter);
                }
            }
        }
    }
}
项目:SurvivalGamesX    文件:CommandManager.java   
public boolean dispatch(CommandSender sender, Command command, String label, String[] args) {
    if (!commands.containsKey(label)) {
        return false;
    }

    boolean handled = true;

    CommandExecutor ce = commands.get(label);
    handled = ce.onCommand(sender, command, label, args);

    return handled;
}
项目:Skyowallet    文件:Bounties.java   
@Override
public Map<String, CommandExecutor> getCommands() {
    final BountyCommand bountyCmd = new BountyCommand();
    for(final CommandInterface command : new CommandInterface[]{new BountyAdd(), new BountyRemove(), new BountyDelete(), new BountyGet(), new BountyList()}) {
        bountyCmd.registerSubCommand(command);
    }
    final Map<String, CommandExecutor> commands = new HashMap<String, CommandExecutor>();
    commands.put("bounty", bountyCmd);
    return commands;
}
项目:NPlugins    文件:NPlugin.java   
/**
 * Associate commands to their executors with a nullcheck.
 *
 * @param commandName the name of the command
 * @param executor    the executor
 *
 * @return if the command was successfully registered
 */
public boolean setCommandExecutor(final String commandName, final CommandExecutor executor) {
    this.debug("- Registering command " + commandName);
    final PluginCommand cuboidCmd = this.getCommand(commandName);
    if (cuboidCmd != null) {
        cuboidCmd.setExecutor(executor);
        return true;
    } else {
        this.error("Command registered by another plugin: " + commandName);
        return false;
    }
}
项目:CommandFramework    文件:BukkitCommand.java   
/**
 * A slimmed down PluginCommand
 * 
 * @param name
 * @param owner
 */
protected BukkitCommand(String label, CommandExecutor executor, Plugin owner) {
    super(label);
    this.executor = executor;
    this.owningPlugin = owner;
    this.usageMessage = "";
}
项目:DisableMobs    文件:DisableMobs.java   
private void setCommandExecutor(String commandName, CommandExecutor executor) {
    PluginCommand command = getCommand(commandName);
    if (command != null)
        command.setExecutor(executor);
    else
        log.severe("Couldn't retrieve plugin command \"" + commandName + "\". Command is not available.");
}
项目:SimpleDev    文件:BukkitCommandHandler.java   
/**
 * Simple command handler for subcommands.
 *
 * @param _sender   The sender that sends the command.
 * @param command   The internal command
 * @param label     The alias used to execute this command.
 * @param arguments The arguments passed to the command.
 */
@Override
public boolean onCommand(CommandSender _sender, org.bukkit.command.Command command, String label, String[] arguments) {
    if (arguments.length == 0) {
        // Make a command out of it.
        arguments = new String[]{CommandHandler.FALLBACK_COMMAND_NAME};
    }

    net.stuxcrystal.simpledev.commands.CommandExecutor<?> sender = ((BukkitPluginBackend) this.backend).wrapSender(_sender);

    if (!this.execute(sender, arguments[0], (String[]) ArrayUtils.remove(arguments, 0)))
        sender.sendMessage(T(sender, "cmd.notfound"));

    return true;
}
项目:helper    文件:ExtendedJavaPlugin.java   
@Nonnull
@Override
public <T extends CommandExecutor> T registerCommand(@Nonnull T command, @Nonnull String... aliases) {
    return CommandMapUtil.registerCommand(this, command, aliases);
}
项目:EscapeLag    文件:CommandInjector.java   
public CommandInjector(Plugin plugin, CommandExecutor commandExecutor, TabCompleter tabCompleter) {
    super(plugin);
    this.commandExecutor = commandExecutor;
    this.tabCompleter = tabCompleter;
}
项目:EscapeLag    文件:CommandInjector.java   
public CommandExecutor getCommandExecutor() {
    return this.commandExecutor;
}
项目:SuperiorCraft    文件:CustomCommand.java   
public void setExecutor(CommandExecutor executer){
    this.executer = executer;
}
项目:mczone    文件:Hive.java   
public void registerCommand(PluginCommand command, CommandExecutor executor) {
    command.setExecutor(new HiveCommandExecutor());
    HiveCommandExecutor.getCommands().put(command.getName(), executor);
}