diff --git a/src/main/java/org/bukkit/craftbukkit/help/DefaultHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/DefaultHelpTopic.java deleted file mode 100644 index 64ba60a7bd..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/help/DefaultHelpTopic.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.bukkit.craftbukkit.help; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.help.HelpTopic; -import org.bukkit.util.ChatPaginator; - -import java.util.Collection; - -/** - * This help topic generates the list of all other help topics. - */ -public class DefaultHelpTopic extends HelpTopic { - - private Collection allTopics; - - public DefaultHelpTopic(Collection allTopics) { - this.allTopics = allTopics; - } - - public boolean canSee(CommandSender sender) { - return true; - } - - public String getName() { - return "Overall"; - } - - public String getShortText() { - return ""; - } - - public String getFullText(CommandSender sender) { - StringBuilder sb = new StringBuilder(); - for (HelpTopic topic : allTopics) { - if (topic.canSee(sender)) { - StringBuilder line = new StringBuilder(); - line.append(ChatColor.GOLD); - line.append(topic.getName()); - line.append(": "); - line.append(ChatColor.WHITE); - line.append(topic.getShortText()); - - String lineStr = line.toString().replace("\n", ". "); - if (sender instanceof Player && lineStr.length() > ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH) { - sb.append(lineStr.substring(0, ChatPaginator.AVERAGE_CHAT_PAGE_WIDTH - 3)); - sb.append("..."); - } else { - sb.append(lineStr); - } - sb.append("\n"); - } - } - return sb.toString(); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/help/GenericCommandHelpTopic.java b/src/main/java/org/bukkit/craftbukkit/help/GenericCommandHelpTopic.java deleted file mode 100644 index 05915d4f37..0000000000 --- a/src/main/java/org/bukkit/craftbukkit/help/GenericCommandHelpTopic.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.bukkit.craftbukkit.help; - -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.apache.commons.lang.StringUtils; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.command.PluginCommand; -import org.bukkit.command.defaults.VanillaCommand; -import org.bukkit.help.HelpTopic; - -public class GenericCommandHelpTopic extends HelpTopic { - - private Command command; - - public GenericCommandHelpTopic(Command command) { - this.command = command; - - if (command.getLabel().startsWith("/")) { - name = command.getLabel(); - } else { - name = "/" + command.getLabel(); - } - - // The short text is the first line of the description - int i = command.getDescription().indexOf("\n"); - if (i > 1) { - shortText = command.getDescription().substring(0, i - 1); - } else { - shortText = command.getDescription(); - } - - // Build full text - StringBuffer sb = new StringBuffer(); - - sb.append(ChatColor.GOLD); - sb.append("Description: "); - sb.append(ChatColor.WHITE); - sb.append(command.getDescription()); - - sb.append("\n"); - - sb.append(ChatColor.GOLD); - sb.append("Usage: "); - sb.append(ChatColor.WHITE); - sb.append(command.getUsage().replace("", name.substring(1))); - - if (command.getAliases().size() > 0) { - sb.append("\n"); - sb.append(ChatColor.GOLD); - sb.append("Aliases: "); - sb.append(ChatColor.WHITE); - sb.append(ChatColor.WHITE + StringUtils.join(command.getAliases(), ", ")); - } - fullText = sb.toString(); - } - - public boolean canSee(CommandSender sender) { - if (!command.isRegistered() && !(command instanceof VanillaCommand)) { - // Unregistered commands should not show up in the help (ignore VanillaCommands) - return false; - } - - if (sender instanceof ConsoleCommandSender) { - return true; - } - - return command.testPermissionSilent(sender); - } -} diff --git a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java index b4843a9415..ee2d05bf3c 100644 --- a/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java +++ b/src/main/java/org/bukkit/craftbukkit/help/SimpleHelpMap.java @@ -6,9 +6,7 @@ import org.bukkit.command.MultipleCommandAlias; import org.bukkit.command.PluginCommand; import org.bukkit.command.defaults.VanillaCommand; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.help.HelpMap; -import org.bukkit.help.HelpTopic; -import org.bukkit.help.HelpTopicFactory; +import org.bukkit.help.*; import java.util.*; @@ -23,7 +21,7 @@ public class SimpleHelpMap implements HelpMap { public SimpleHelpMap() { helpTopics = new TreeMap(new HelpTopicComparator()); // Using a TreeMap for its explicit sorting on key - defaultTopic = new DefaultHelpTopic(helpTopics.values()); + defaultTopic = new IndexHelpTopic(helpTopics.values()); topicFactoryMap = new HashMap(); registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());