diff options
author | rmichela <deltahat@gmail.com> | 2012-03-21 23:01:06 -0400 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-03-22 00:50:09 -0400 |
commit | eb3c092ef8bed36a057a5404fa1e0723e58aa2b9 (patch) | |
tree | 4c7e5b2c2ee185172d5f89eeb46f4fabe57e6fd6 /src | |
parent | 31b1bc02ca968d7282c7fdc734e67b23d6ee93e5 (diff) | |
download | craftbukkit-eb3c092ef8bed36a057a5404fa1e0723e58aa2b9.tar craftbukkit-eb3c092ef8bed36a057a5404fa1e0723e58aa2b9.tar.gz craftbukkit-eb3c092ef8bed36a057a5404fa1e0723e58aa2b9.tar.lz craftbukkit-eb3c092ef8bed36a057a5404fa1e0723e58aa2b9.tar.xz craftbukkit-eb3c092ef8bed36a057a5404fa1e0723e58aa2b9.zip |
[Bleeding] Added option to completely disable all automatic help topic generation by adding "All" to the ignore-plugins list in help.yml. Addresses BUKKIT-1264
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java | 23 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java | 5 | ||||
-rw-r--r-- | src/main/resources/configurations/help.yml | 3 |
3 files changed, 22 insertions, 9 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java index 158a781c..884fe396 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java +++ b/src/main/java/org/bukkit/craftbukkit/help/HelpYamlReader.java @@ -17,21 +17,28 @@ import java.util.logging.Level; */ public class HelpYamlReader { - private final YamlConfiguration helpYaml; + private YamlConfiguration helpYaml; private final char ALT_COLOR_CODE = '&'; public HelpYamlReader(Server server) { File helpYamlFile = new File("help.yml"); + YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(getClass().getClassLoader().getResourceAsStream("configurations/help.yml")); - helpYaml = YamlConfiguration.loadConfiguration(helpYamlFile); - helpYaml.options().copyDefaults(true); - helpYaml.setDefaults(YamlConfiguration.loadConfiguration(getClass().getClassLoader().getResourceAsStream("configurations/help.yml"))); try { - if (!helpYamlFile.exists()) { - helpYaml.save(helpYamlFile); + helpYaml = YamlConfiguration.loadConfiguration(helpYamlFile); + helpYaml.options().copyDefaults(true); + helpYaml.setDefaults(defaultConfig); + + try { + if (!helpYamlFile.exists()) { + helpYaml.save(helpYamlFile); + } + } catch (IOException ex) { + server.getLogger().log(Level.SEVERE, "Could not save " + helpYamlFile, ex); } - } catch (IOException ex) { - server.getLogger().log(Level.SEVERE, "Could not save " + helpYamlFile, ex); + } catch (Exception ex) { + server.getLogger().severe("Failed to load help.yml. Verify the yaml indentation is correct. Reverting to default help.yml."); + helpYaml = defaultConfig; } } diff --git a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java index cdde69ce..4e4604e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java +++ b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java @@ -90,6 +90,11 @@ public class SimpleHelpMap implements HelpMap { public synchronized void initializeCommands() { // ** Load topics from highest to lowest priority order ** Set<String> ignoredPlugins = new HashSet<String>(yaml.getIgnoredPlugins()); + + // Don't load any automatic help topics if All is ignored + if (ignoredPlugins.contains("All")) { + return; + } // Initialize help topics from the server's command map outer: for (Command command : server.getCommandMap().getCommands()) { diff --git a/src/main/resources/configurations/help.yml b/src/main/resources/configurations/help.yml index d7f363b1..faa7d569 100644 --- a/src/main/resources/configurations/help.yml +++ b/src/main/resources/configurations/help.yml @@ -33,7 +33,8 @@ # 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. +# the /plugins command. Ignore "Bukkit" to remove the standard bukkit commands from the index. Ignore "All" +# to completely disable automatic help topic generation. # ignore-plugins: # - PluginNameOne # - PluginNameTwo |