diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/help/GenericCommandHelpTopic.java | 2 | ||||
-rw-r--r-- | src/main/java/org/bukkit/help/IndexHelpTopic.java | 42 |
2 files changed, 27 insertions, 17 deletions
diff --git a/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java b/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java index be441862..1bcf4719 100644 --- a/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java +++ b/src/main/java/org/bukkit/help/GenericCommandHelpTopic.java @@ -16,7 +16,7 @@ import org.bukkit.help.HelpTopic; */ public class GenericCommandHelpTopic extends HelpTopic { - private Command command; + protected Command command; public GenericCommandHelpTopic(Command command) { this.command = command; diff --git a/src/main/java/org/bukkit/help/IndexHelpTopic.java b/src/main/java/org/bukkit/help/IndexHelpTopic.java index 50053bcc..559d2e68 100644 --- a/src/main/java/org/bukkit/help/IndexHelpTopic.java +++ b/src/main/java/org/bukkit/help/IndexHelpTopic.java @@ -2,6 +2,7 @@ package org.bukkit.help; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import org.bukkit.help.HelpTopic; import org.bukkit.util.ChatPaginator; @@ -10,35 +11,44 @@ import java.util.Collection; /** * This help topic generates a list of other help topics. This class is useful for adding your own - * index help topics. + * index help topics. To enforce a particular order, use a sorted collection. */ public class IndexHelpTopic extends HelpTopic { + private String permission; + private String preamble; private Collection<HelpTopic> allTopics; - /** - * Creates an index help topic from a collection of help topics. The index is displayed in the order of the - * topic collection's iterator. To enforce a particular order, use a sorted collection. - * @param topics The collection of topics to use display in an index. - */ - public IndexHelpTopic(Collection<HelpTopic> topics) { + public IndexHelpTopic(String name, String shortText, String permission, Collection<HelpTopic> topics) { + this(name, shortText, permission, topics, null); + } + + public IndexHelpTopic(String name, String shortText, String permission, Collection<HelpTopic> topics, String preamble) { + this.name = name; + this.shortText = shortText; + this.permission = permission; this.allTopics = topics; + this.preamble = preamble; } public boolean canSee(CommandSender sender) { - return true; - } - - public String getName() { - return "Overall"; - } - - public String getShortText() { - return ""; + if (sender instanceof ConsoleCommandSender) { + return true; + } + if (permission == null) { + return true; + } + return sender.hasPermission(permission); } public String getFullText(CommandSender sender) { StringBuilder sb = new StringBuilder(); + + if (preamble != null) { + sb.append(preamble); + sb.append("\n"); + } + for (HelpTopic topic : allTopics) { if (topic.canSee(sender)) { StringBuilder line = new StringBuilder(); |