Commits
t00thpick1 authored and Travis Watkins committed cc8bac36166
1 1 | package org.bukkit.command.defaults; |
2 2 | |
3 3 | import java.util.ArrayList; |
4 + | import java.util.Arrays; |
4 5 | import java.util.HashMap; |
5 6 | import java.util.List; |
6 7 | import java.util.Map; |
7 8 | import java.util.Set; |
8 9 | import java.util.TreeSet; |
9 10 | |
10 11 | import org.apache.commons.lang.ArrayUtils; |
11 12 | import org.apache.commons.lang.StringUtils; |
12 13 | import org.apache.commons.lang.Validate; |
13 14 | import org.apache.commons.lang.math.NumberUtils; |
21 22 | import org.bukkit.help.IndexHelpTopic; |
22 23 | import org.bukkit.util.ChatPaginator; |
23 24 | |
24 25 | import com.google.common.collect.ImmutableList; |
25 26 | |
26 27 | public class HelpCommand extends VanillaCommand { |
27 28 | public HelpCommand() { |
28 29 | super("help"); |
29 30 | this.description = "Shows the help menu"; |
30 31 | this.usageMessage = "/help <pageNumber>\n/help <topic>\n/help <topic> <pageNumber>"; |
32 + | this.setAliases(Arrays.asList(new String[] { "?" })); |
31 33 | this.setPermission("bukkit.command.help"); |
32 34 | } |
33 35 | |
34 36 | |
35 37 | public boolean execute(CommandSender sender, String currentAlias, String[] args) { |
36 38 | if (!testPermission(sender)) return true; |
37 39 | |
38 40 | String command; |
39 41 | int pageNumber; |
40 42 | int pageHeight; |
102 104 | for (int i = header.length(); i < ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH; i++) { |
103 105 | header.append("-"); |
104 106 | } |
105 107 | sender.sendMessage(header.toString()); |
106 108 | |
107 109 | sender.sendMessage(page.getLines()); |
108 110 | |
109 111 | return true; |
110 112 | } |
111 113 | |
112 - | |
113 - | public boolean matches(String input) { |
114 - | return input.equalsIgnoreCase("help") || input.equalsIgnoreCase("?"); |
115 - | } |
116 - | |
117 114 | |
118 115 | public List<String> tabComplete(CommandSender sender, String alias, String[] args) { |
119 116 | Validate.notNull(sender, "Sender cannot be null"); |
120 117 | Validate.notNull(args, "Arguments cannot be null"); |
121 118 | Validate.notNull(alias, "Alias cannot be null"); |
122 119 | |
123 120 | if (args.length == 1) { |
124 121 | List<String> matchedTopics = new ArrayList<String>(); |
125 122 | String searchString = args[0]; |
126 123 | for (HelpTopic topic : Bukkit.getServer().getHelpMap().getHelpTopics()) { |