Package org.bukkit.command

Examples of org.bukkit.command.CommandMap


        return command;
    }


    private static CommandMap getCommandMap() {
        CommandMap commandMap = null;

        try {
            if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
                Field f = SimplePluginManager.class.getDeclaredField("commandMap");
                f.setAccessible(true);
View Full Code Here


        this.plugin = plugin;
        this.executor = executor;
    }

    public boolean register(List<CommandInfo> registered) {
        CommandMap commandMap = getCommandMap();
        if (registered == null || commandMap == null) {
            return false;
        }
        for (CommandInfo command : registered) {
            DynamicPluginCommand cmd = new DynamicPluginCommand(command.getAliases(),
                    command.getDesc(), "/" + command.getAliases()[0] + " " + command.getUsage(), executor, command.getRegisteredWith(), plugin);
            cmd.setPermissions(command.getPermissions());
            commandMap.register(plugin.getDescription().getName(), cmd);
        }
        return true;
    }
View Full Code Here

        }
        return true;
    }

    public CommandMap getCommandMap() {
        CommandMap commandMap = ReflectionUtil.getField(plugin.getServer().getPluginManager(), "commandMap");
        if (commandMap == null) {
            if (fallbackCommands != null) {
                commandMap = fallbackCommands;
            } else {
                Bukkit.getServer().getLogger().severe(plugin.getDescription().getName() +
View Full Code Here

        }
        return commandMap;
    }

    public boolean unregisterCommands() {
        CommandMap commandMap = getCommandMap();
        List<String> toRemove = new ArrayList<String>();
        Map<String, org.bukkit.command.Command> knownCommands = ReflectionUtil.getField(commandMap, "knownCommands");
        Set<String> aliases = ReflectionUtil.getField(commandMap, "aliases");
        if (knownCommands == null || aliases == null) {
            return false;
View Full Code Here

     */
    public static Collection<Command> getCommands() {
        final Collection<Command> commands = new LinkedHashSet<Command>(500);

        // All (?) commands from the SimpleCommandMap of the server, if available.
        final CommandMap commandMap = getCommandMap();
        if (commandMap != null && commandMap instanceof SimpleCommandMap) {
            commands.addAll(((SimpleCommandMap) commandMap).getCommands());
        }
        // TODO: Fall-back for Vanilla / CB commands? [Fall-back should be altering permission defaults, though negating permissions is the right way.]

View Full Code Here

     * @param alias
     * @return
     */
    public static Command getCommand(final String alias) {
        final String lcAlias = alias.trim().toLowerCase();
        final CommandMap map = getCommandMap();
        if (map != null) {
            return map.getCommand(lcAlias);
        } else {
            // TODO: maybe match versus plugin commands.
            return null;
        }
    }
View Full Code Here

            server.getPluginManager().registerEvents(this, DenizenAPI.getCurrentInstance());

            // Get the CommandMap for the server
            final Field commandMapField = server.getClass().getDeclaredField("commandMap");
            commandMapField.setAccessible(true);
            CommandMap commandMap = (CommandMap) commandMapField.get(server);

            // Get the knownCommands for the server's CommandMap
            final Field knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
            knownCommandsField.setAccessible(true);
            knownCommands = (Map<String, Command>) knownCommandsField.get(commandMap);

            // Get the HelpMap for the server
            HelpMap helpMap = server.getHelpMap();
View Full Code Here

    /**
     * Register commands.
     */
    public static void registerCommands()
    {
        CommandMap commandMap = null;
        try
        {
            Field field = Bukkit.getServer().getPluginManager().getClass().getDeclaredField("commandMap");
            field.setAccessible(true);
            commandMap = (CommandMap) (field.get(Bukkit.getServer().getPluginManager()));
        } catch (NoSuchFieldException e)
        {
            e.printStackTrace();
        } catch (IllegalAccessException e)
        {
            e.printStackTrace();
        }

        String[] aliases = { "CreeperHeal", CreeperConfig.getAlias() };
        CreeperCommand com = new CreeperCommand(aliases, "", "", new CreeperCommandManager());

        if (commandMap != null)
            commandMap.register("_", com);

    }
View Full Code Here

            sender.sendMessage(sb.toString());
        }
    }

    public org.bukkit.command.Command getCommand(String name) {
        CommandMap commandMap = ReflectionUtil.getField(CommandBook.server().getPluginManager(),
                "commandMap");
        if (commandMap == null) {
            return null;
        }
        return commandMap.getCommand(name);
    }
View Full Code Here

        }
        return commandMap.getCommand(name);
    }

    public Collection<org.bukkit.command.Command> getServerCommands() {
        CommandMap commandMap = ReflectionUtil.getField(CommandBook.server().getPluginManager(),
                "commandMap");
        if (commandMap == null) {
            return Collections.emptySet();
        }
        Set<org.bukkit.command.Command> cmds = new HashSet<org.bukkit.command.Command>();
View Full Code Here

TOP

Related Classes of org.bukkit.command.CommandMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.