summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorrmichela <deltahat@gmail.com>2012-03-15 22:32:31 -0400
committerEvilSeph <evilseph@gmail.com>2012-03-16 03:10:25 -0400
commit46429c6cb948f5338f253c1e22cce459704d773b (patch)
tree03780dba830302e72484883842dd24def9fe5d31 /src
parentf87e053c66cd229730bf8a4faba834ce7393f5f7 (diff)
downloadcraftbukkit-46429c6cb948f5338f253c1e22cce459704d773b.tar
craftbukkit-46429c6cb948f5338f253c1e22cce459704d773b.tar.gz
craftbukkit-46429c6cb948f5338f253c1e22cce459704d773b.tar.lz
craftbukkit-46429c6cb948f5338f253c1e22cce459704d773b.tar.xz
craftbukkit-46429c6cb948f5338f253c1e22cce459704d773b.zip
[Bleeding] Implemented the command-topics-in-master-index option in help.yml. Addresses BUKKIT-1189
When false, help topics that start with a slash are omitted from the mater index.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java37
-rw-r--r--src/main/resources/configurations/help.yml3
3 files changed, 32 insertions, 12 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
index 064833f1..abef75e7 100644
--- a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
+++ b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java
@@ -74,4 +74,8 @@ public class HelpYamlReader {
public List<String> getIgnoredPlugins() {
return helpYaml.getStringList("ignore-plugins");
}
+
+ public boolean commandTopicsInMasterIndex() {
+ return helpYaml.getBoolean("command-topics-in-master-index", true);
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java
index d5696c84..1fc57a09 100644
--- a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java
+++ b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java
@@ -1,15 +1,16 @@
package org.bukkit.craftbukkit.help;
+import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import org.bukkit.ChatColor;
-import org.bukkit.Server;
import org.bukkit.command.*;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.command.defaults.VanillaCommand;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.help.*;
+import javax.annotation.Nullable;
import java.util.*;
/**
@@ -22,13 +23,21 @@ public class SimpleHelpMap implements HelpMap {
private Set<HelpTopic> pluginIndexes;
private Map<Class, HelpTopicFactory<Command>> topicFactoryMap;
private CraftServer server;
+ private HelpYamlReader yaml;
public SimpleHelpMap(CraftServer server) {
- helpTopics = new TreeMap<String, HelpTopic>(new HelpTopicComparator.TopicNameComparator()); // Using a TreeMap for its explicit sorting on key
- pluginIndexes = new TreeSet<HelpTopic>(new HelpTopicComparator());
- defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(helpTopics.values(), Predicates.not(Predicates.instanceOf(CommandAliasHelpTopic.class))));
- topicFactoryMap = new HashMap<Class, HelpTopicFactory<Command>>();
+ this.helpTopics = new TreeMap<String, HelpTopic>(new HelpTopicComparator.TopicNameComparator()); // Using a TreeMap for its explicit sorting on key
+ this.pluginIndexes = new TreeSet<HelpTopic>(new HelpTopicComparator());
+ this.topicFactoryMap = new HashMap<Class, HelpTopicFactory<Command>>();
this.server = server;
+ this.yaml = new HelpYamlReader(server);
+
+ Predicate indexFilter = Predicates.not(Predicates.instanceOf(CommandAliasHelpTopic.class));
+ if (!yaml.commandTopicsInMasterIndex()) {
+ indexFilter = Predicates.and(indexFilter, Predicates.not(new IsCommandTopicPredicate()));
+ }
+
+ this.defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(helpTopics.values(), indexFilter));
registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
}
@@ -61,17 +70,15 @@ public class SimpleHelpMap implements HelpMap {
}
public List<String> getIgnoredPlugins() {
- return new HelpYamlReader(server).getIgnoredPlugins();
+ return yaml.getIgnoredPlugins();
}
/**
* Reads the general topics from help.yml and adds them to the help index.
*/
public synchronized void initializeGeneralTopics() {
- HelpYamlReader reader = new HelpYamlReader(server);
-
// Initialize general help topics from the help.yml file
- for (HelpTopic topic : reader.getGeneralTopics()) {
+ for (HelpTopic topic : yaml.getGeneralTopics()) {
addTopic(topic);
}
}
@@ -81,8 +88,7 @@ public class SimpleHelpMap implements HelpMap {
*/
public synchronized void initializeCommands() {
// ** Load topics from highest to lowest priority order **
- HelpYamlReader helpYamlReader = new HelpYamlReader(server);
- List<String> ignoredPlugins = helpYamlReader.getIgnoredPlugins();
+ List<String> ignoredPlugins = yaml.getIgnoredPlugins();
// Initialize help topics from the server's command map
outer: for (Command command : server.getCommandMap().getCommands()) {
@@ -136,7 +142,7 @@ public class SimpleHelpMap implements HelpMap {
}
// Amend help topics from the help.yml file
- for (HelpTopicAmendment amendment : helpYamlReader.getTopicAmendments()) {
+ for (HelpTopicAmendment amendment : yaml.getTopicAmendments()) {
if (helpTopics.containsKey(amendment.getTopicName())) {
helpTopics.get(amendment.getTopicName()).amendTopic(amendment.getShortText(), amendment.getFullText());
if (amendment.getPermission() != null) {
@@ -187,4 +193,11 @@ public class SimpleHelpMap implements HelpMap {
}
topicFactoryMap.put(commandClass, factory);
}
+
+ private class IsCommandTopicPredicate implements Predicate<HelpTopic> {
+
+ public boolean apply(@Nullable HelpTopic topic) {
+ return topic.getName().charAt(0) == '/';
+ }
+ }
}
diff --git a/src/main/resources/configurations/help.yml b/src/main/resources/configurations/help.yml
index 1a4ac9fc..5e6ed5b9 100644
--- a/src/main/resources/configurations/help.yml
+++ b/src/main/resources/configurations/help.yml
@@ -11,6 +11,9 @@
# 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.
# --
+# Set this to true to list the individual command help topics in the master help.
+# command-topics-in-master-index: true
+# --
# Each general topic will show up as a separate topic in the help index along with all the plugin command topics.
# general-topics:
# rules: