summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorrmichela <deltahat@gmail.com>2012-03-14 23:39:19 -0400
committerEvilSeph <evilseph@gmail.com>2012-03-16 02:44:05 -0400
commit184faf1f299df4f821c287bc179f106c78efbbc5 (patch)
treee5d5a1aceaca6a7ef3699c896270b73c3fa0b554 /src
parentfc697a4f440829c6813b198b9e1e0a87789e042b (diff)
downloadcraftbukkit-184faf1f299df4f821c287bc179f106c78efbbc5.tar
craftbukkit-184faf1f299df4f821c287bc179f106c78efbbc5.tar.gz
craftbukkit-184faf1f299df4f821c287bc179f106c78efbbc5.tar.lz
craftbukkit-184faf1f299df4f821c287bc179f106c78efbbc5.tar.xz
craftbukkit-184faf1f299df4f821c287bc179f106c78efbbc5.zip
[Bleeding] Added option to remove entire plugins from the help index using the help.yml file. Addresses BUKKIT-1178
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java6
-rw-r--r--src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java51
-rw-r--r--src/main/resources/configurations/help.yml19
4 files changed, 63 insertions, 17 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 5801e2e2..617676a7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -129,7 +129,7 @@ public final class CraftServer implements Server {
private final ServicesManager servicesManager = new SimpleServicesManager();
private final BukkitScheduler scheduler = new CraftScheduler();
private final SimpleCommandMap commandMap = new SimpleCommandMap(this);
- private final SimpleHelpMap helpMap = new SimpleHelpMap();
+ private final SimpleHelpMap helpMap = new SimpleHelpMap(this);
private final StandardMessenger messenger = new StandardMessenger();
private final PluginManager pluginManager = new SimplePluginManager(this, commandMap);
protected final MinecraftServer console;
@@ -222,7 +222,7 @@ public final class CraftServer implements Server {
public void enablePlugins(PluginLoadOrder type) {
if (type == PluginLoadOrder.STARTUP) {
helpMap.clear();
- helpMap.initializeGeneralTopics(this);
+ helpMap.initializeGeneralTopics();
}
Plugin[] plugins = pluginManager.getPlugins();
@@ -237,7 +237,7 @@ public final class CraftServer implements Server {
commandMap.registerServerAliases();
loadCustomPermissions();
DefaultPermissions.registerCorePermissions();
- helpMap.initializeCommands(this);
+ helpMap.initializeCommands();
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
index dfa8d9a4..064833f1 100644
--- a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
+++ b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
@@ -70,4 +70,8 @@ public class HelpYamlReader {
}
return amendments;
}
+
+ public List<String> getIgnoredPlugins() {
+ return helpYaml.getStringList("ignore-plugins");
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java
index 01eb5533..d7313ff1 100644
--- a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java
@@ -2,10 +2,12 @@ package org.bukkit.craftbukkit.help;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
+import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.MultipleCommandAlias;
import org.bukkit.command.PluginCommand;
+import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.command.defaults.VanillaCommand;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.help.*;
@@ -19,12 +21,14 @@ public class SimpleHelpMap implements HelpMap {
private HelpTopic defaultTopic;
private Map<String, HelpTopic> helpTopics;
- private Map<Class, HelpTopicFactory> topicFactoryMap;
+ private Map<Class, HelpTopicFactory<Command>> topicFactoryMap;
+ private CraftServer server;
- public SimpleHelpMap() {
+ public SimpleHelpMap(CraftServer server) {
helpTopics = new TreeMap<String, HelpTopic>(new HelpTopicComparator()); // Using a TreeMap for its explicit sorting on key
defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(helpTopics.values(), Predicates.not(Predicates.instanceOf(CommandAliasHelpTopic.class))));
- topicFactoryMap = new HashMap<Class, HelpTopicFactory>();
+ topicFactoryMap = new HashMap<Class, HelpTopicFactory<Command>>();
+ this.server = server;
registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
}
@@ -52,11 +56,14 @@ public class SimpleHelpMap implements HelpMap {
helpTopics.clear();
}
+ public List<String> getIgnoredPlugins() {
+ return new HelpYamlReader(server).getIgnoredPlugins();
+ }
+
/**
* Reads the general topics from help.yml and adds them to the help index.
- * @param server A reference to the server.
*/
- public synchronized void initializeGeneralTopics(CraftServer server) {
+ public synchronized void initializeGeneralTopics() {
HelpYamlReader reader = new HelpYamlReader(server);
// Initialize general help topics from the help.yml file
@@ -67,14 +74,19 @@ public class SimpleHelpMap implements HelpMap {
/**
* Processes all the commands registered in the server and creates help topics for them.
- * @param server A reference to the server.
*/
- @SuppressWarnings("unchecked")
- public synchronized void initializeCommands(CraftServer server) {
+ public synchronized void initializeCommands() {
// ** Load topics from highest to lowest priority order **
+ HelpYamlReader helpYamlReader = new HelpYamlReader(server);
+ List<String> ignoredPlugins = helpYamlReader.getIgnoredPlugins();
// Initialize help topics from the server's command map
outer: for (Command command : server.getCommandMap().getCommands()) {
+ if (commandInIgnoredPlugin(command, ignoredPlugins)) {
+ continue outer;
+ }
+
+ // Register a topic
for (Class c : topicFactoryMap.keySet()) {
if (c.isAssignableFrom(command.getClass())) {
addTopic(topicFactoryMap.get(c).createTopic(command));
@@ -90,6 +102,9 @@ public class SimpleHelpMap implements HelpMap {
// Initialize command alias help topics
for (Command command : server.getCommandMap().getCommands()) {
+ if (commandInIgnoredPlugin(command, ignoredPlugins)) {
+ continue;
+ }
for (String alias : command.getAliases()) {
addTopic(new CommandAliasHelpTopic(alias, command.getLabel(), this));
}
@@ -97,15 +112,16 @@ public class SimpleHelpMap implements HelpMap {
// Initialize help topics from the server's fallback commands
for (VanillaCommand command : server.getCommandMap().getFallbackCommands()) {
- addTopic(new GenericCommandHelpTopic(command));
+ if (!commandInIgnoredPlugin(command, ignoredPlugins)) {
+ addTopic(new GenericCommandHelpTopic(command));
+ }
}
// Add alias sub-index
addTopic(new IndexHelpTopic("Aliases", "Lists command aliases", null, Collections2.filter(helpTopics.values(), Predicates.instanceOf(CommandAliasHelpTopic.class))));
// Amend help topics from the help.yml file
- HelpYamlReader reader = new HelpYamlReader(server);
- for (HelpTopicAmendment amendment : reader.getTopicAmendments()) {
+ for (HelpTopicAmendment amendment : helpYamlReader.getTopicAmendments()) {
if (helpTopics.containsKey(amendment.getTopicName())) {
helpTopics.get(amendment.getTopicName()).amendTopic(amendment.getShortText(), amendment.getFullText());
if (amendment.getPermission() != null) {
@@ -114,6 +130,19 @@ public class SimpleHelpMap implements HelpMap {
}
}
}
+
+ private boolean commandInIgnoredPlugin(Command command, List<String> ignoredPlugins) {
+ if (command instanceof BukkitCommand && ignoredPlugins.contains("Bukkit")) {
+ return true;
+ }
+ if (command instanceof VanillaCommand && ignoredPlugins.contains("Bukkit")) {
+ return true;
+ }
+ if (command instanceof PluginCommand && ignoredPlugins.contains(((PluginCommand)command).getPlugin().getName())) {
+ return true;
+ }
+ return false;
+ }
public void registerHelpTopicFactory(Class commandClass, HelpTopicFactory factory) {
if (!Command.class.isAssignableFrom(commandClass) && !CommandExecutor.class.isAssignableFrom(commandClass)) {
diff --git a/src/main/resources/configurations/help.yml b/src/main/resources/configurations/help.yml
index 715ddd3e..1a4ac9fc 100644
--- a/src/main/resources/configurations/help.yml
+++ b/src/main/resources/configurations/help.yml
@@ -3,10 +3,15 @@
# or extracted from your installed plugins. You only need to modify this file if you wish to add new help pages to
# your server or override the help pages of existing plugin commands.
# --
-# This file is divided up into two parts: general-topics and command-topics respectively. Examples are given below.
-# Color codes are allowed. When amending command topic, the string <text> will be replaced with the existing value
-# in the help topic.
+# This file is divided up into the following parts:
+# -- general-topics: lists admin defined topics
+# -- amend-topics: lists topic amendments to apply to existing help topics
+# -- ignore-plugins: lists any plugins that should be excluded from help
+# general-topics and command-topics respectively.
+# Examples are given below. Color codes are allowed. When amending command topic, the string <text> will be replaced
+# with the existing value in the help topic.
# --
+# Each general topic will show up as a separate topic in the help index along with all the plugin command topics.
# general-topics:
# rules:
# shortText: Rules of the server
@@ -16,8 +21,16 @@
# 3. No swearing.
# permission: topics.rules
# --
+# Topic amendments are used to change the content of automatically generated plugin command topics.
# amended-topics:
# /stop:
# shortText: Stops the server cold....in its tracks!
# fullText: <text> - This kills the server.
# permission: you.dont.have
+# --
+# Any plugin in the ignored plugins list will be excluded from help. The name must match the name displayed by
+# the /plugins command. Ignore "Bukkit" to remove the standard bukkit commands from the index.
+# ignore-plugins:
+# - PluginNameOne
+# - PluginNameTwo
+# - PluginNameThree