Search in sources :

Example 1 with GenericCommandHelpTopic

use of org.bukkit.help.GenericCommandHelpTopic in project Arcade2 by ShootGame.

the class BukkitCommands method injectCommand.

private void injectCommand(String prefix, Command command) {
    org.bukkit.command.Command performer = this.createBukkitCommand(command);
    this.bukkitCommandMap.register(prefix, performer);
    this.helpTopics.add(new GenericCommandHelpTopic(performer));
}
Also used : GenericCommandHelpTopic(org.bukkit.help.GenericCommandHelpTopic)

Example 2 with GenericCommandHelpTopic

use of org.bukkit.help.GenericCommandHelpTopic in project Fusion by GummyPvP.

the class CommandFramework method registerHelp.

/**
 * Registers all the commands under the plugin's help
 */
public void registerHelp() {
    Set<HelpTopic> help = new TreeSet<HelpTopic>(HelpTopicComparator.helpTopicComparatorInstance());
    for (String s : commandMap.keySet()) {
        if (!s.contains(".")) {
            org.bukkit.command.Command cmd = map.getCommand(s);
            HelpTopic topic = new GenericCommandHelpTopic(cmd);
            help.add(topic);
        }
    }
    IndexHelpTopic topic = new IndexHelpTopic(plugin.getName(), "All commands for " + plugin.getName(), null, help, "Below is a list of all " + plugin.getName() + " commands:");
    Bukkit.getServer().getHelpMap().addTopic(topic);
}
Also used : TreeSet(java.util.TreeSet) HelpTopic(org.bukkit.help.HelpTopic) IndexHelpTopic(org.bukkit.help.IndexHelpTopic) GenericCommandHelpTopic(org.bukkit.help.GenericCommandHelpTopic) IndexHelpTopic(org.bukkit.help.IndexHelpTopic) GenericCommandHelpTopic(org.bukkit.help.GenericCommandHelpTopic)

Example 3 with GenericCommandHelpTopic

use of org.bukkit.help.GenericCommandHelpTopic in project Glowstone by GlowstoneMC.

the class GlowHelpMap method initializeCommands.

/**
 * Processes all the commands registered in the server and creates help topics for them.
 */
public synchronized void initializeCommands() {
    // Don't load any automatic help topics if All is ignored
    if (ignoredPlugins.contains("All")) {
        return;
    }
    Collection<Command> commands = server.getCommandMap().getCommands();
    // Initialize help topics from the server's command map
    outer: for (Command command : commands) {
        if (commandInIgnoredPlugin(command)) {
            continue;
        }
        // Register a topic
        for (Entry<Class, HelpTopicFactory<Command>> entry : topicFactoryMap.entrySet()) {
            if (((Class<?>) entry.getKey()).isAssignableFrom(command.getClass())) {
                HelpTopic t = entry.getValue().createTopic(command);
                if (t != null) {
                    addCommandTopic(t);
                }
                continue outer;
            }
            if (command instanceof PluginCommand && ((Class<?>) entry.getKey()).isAssignableFrom(((PluginCommand) command).getExecutor().getClass())) {
                HelpTopic t = entry.getValue().createTopic(command);
                if (t != null) {
                    addCommandTopic(t);
                }
                continue outer;
            }
        }
        addCommandTopic(new GenericCommandHelpTopic(command));
    }
    // Alias topics for commands
    Set<HelpTopic> aliases = new TreeSet<>(TOPIC_COMPARE);
    for (Command command : commands) {
        if (commandInIgnoredPlugin(command)) {
            continue;
        }
        HelpTopic original = getHelpTopic("/" + command.getLabel());
        if (original != null) {
            for (String alias : command.getAliases()) {
                HelpTopic aliasTopic = new AliasTopic("/" + alias, original);
                if (!helpTopics.containsKey(aliasTopic.getName())) {
                    aliases.add(aliasTopic);
                    addPrivateTopic(aliasTopic);
                }
            }
        }
    }
    // Aliases index topic
    if (!aliases.isEmpty()) {
        addTopic(new IndexHelpTopic("Aliases", "Lists command aliases", null, aliases, null));
    }
    // Initialize plugin-level sub-topics
    Map<String, Set<HelpTopic>> pluginIndexes = new HashMap<>();
    for (Command command : commands) {
        String pluginName = getCommandPluginName(command);
        if (pluginName != null) {
            HelpTopic topic = getHelpTopic("/" + command.getLabel());
            if (topic != null) {
                if (!pluginIndexes.containsKey(pluginName)) {
                    pluginIndexes.put(pluginName, new TreeSet<>(TOPIC_COMPARE));
                }
                pluginIndexes.get(pluginName).add(topic);
            }
        }
    }
    for (Entry<String, Set<HelpTopic>> entry : pluginIndexes.entrySet()) {
        String key = entry.getKey();
        addTopic(new IndexHelpTopic(key, "All commands for " + key, null, entry.getValue(), "Below is a list of all " + key + " commands:"));
    }
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) HelpTopic(org.bukkit.help.HelpTopic) IndexHelpTopic(org.bukkit.help.IndexHelpTopic) GenericCommandHelpTopic(org.bukkit.help.GenericCommandHelpTopic) GenericCommandHelpTopic(org.bukkit.help.GenericCommandHelpTopic) Entry(java.util.Map.Entry) PluginIdentifiableCommand(org.bukkit.command.PluginIdentifiableCommand) PluginCommand(org.bukkit.command.PluginCommand) BukkitCommand(org.bukkit.command.defaults.BukkitCommand) Command(org.bukkit.command.Command) TreeSet(java.util.TreeSet) IndexHelpTopic(org.bukkit.help.IndexHelpTopic) PluginCommand(org.bukkit.command.PluginCommand)

Aggregations

GenericCommandHelpTopic (org.bukkit.help.GenericCommandHelpTopic)3 TreeSet (java.util.TreeSet)2 HelpTopic (org.bukkit.help.HelpTopic)2 IndexHelpTopic (org.bukkit.help.IndexHelpTopic)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Command (org.bukkit.command.Command)1 PluginCommand (org.bukkit.command.PluginCommand)1 PluginIdentifiableCommand (org.bukkit.command.PluginIdentifiableCommand)1 BukkitCommand (org.bukkit.command.defaults.BukkitCommand)1