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));
}
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);
}
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:"));
}
}
Aggregations