Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
CommandMap.java
1 package org.bukkit.command;
2 
3 import java.util.List;
4 
5 public interface CommandMap {
6 
7  /**
8  * Registers all the commands belonging to a certain plugin.
9  * <p>
10  * Caller can use:-
11  * <ul>
12  * <li>command.getName() to determine the label registered for this
13  * command
14  * <li>command.getAliases() to determine the aliases which where
15  * registered
16  * </ul>
17  *
18  * @param fallbackPrefix a prefix which is prepended to each command with
19  * a ':' one or more times to make the command unique
20  * @param commands a list of commands to register
21  */
22  public void registerAll(String fallbackPrefix, List<Command> commands);
23 
24  /**
25  * Registers a command. Returns true on success; false if name is already
26  * taken and fallback had to be used.
27  * <p>
28  * Caller can use:-
29  * <ul>
30  * <li>command.getName() to determine the label registered for this
31  * command
32  * <li>command.getAliases() to determine the aliases which where
33  * registered
34  * </ul>
35  *
36  * @param label the label of the command, without the '/'-prefix.
37  * @param fallbackPrefix a prefix which is prepended to the command with a
38  * ':' one or more times to make the command unique
39  * @param command the command to register
40  * @return true if command was registered with the passed in label, false
41  * otherwise, which indicates the fallbackPrefix was used one or more
42  * times
43  */
44  public boolean register(String label, String fallbackPrefix, Command command);
45 
46  /**
47  * Registers a command. Returns true on success; false if name is already
48  * taken and fallback had to be used.
49  * <p>
50  * Caller can use:-
51  * <ul>
52  * <li>command.getName() to determine the label registered for this
53  * command
54  * <li>command.getAliases() to determine the aliases which where
55  * registered
56  * </ul>
57  *
58  * @param fallbackPrefix a prefix which is prepended to the command with a
59  * ':' one or more times to make the command unique
60  * @param command the command to register, from which label is determined
61  * from the command name
62  * @return true if command was registered with the passed in label, false
63  * otherwise, which indicates the fallbackPrefix was used one or more
64  * times
65  */
66  public boolean register(String fallbackPrefix, Command command);
67 
68  /**
69  * Looks for the requested command and executes it if found.
70  *
71  * @param sender The command's sender
72  * @param cmdLine command + arguments. Example: "/test abc 123"
73  * @return returns false if no target is found, true otherwise.
74  * @throws CommandException Thrown when the executor for the given command
75  * fails with an unhandled exception
76  */
77  public boolean dispatch(CommandSender sender, String cmdLine) throws CommandException;
78 
79  /**
80  * Clears all registered commands.
81  */
82  public void clearCommands();
83 
84  /**
85  * Gets the command registered to the specified name
86  *
87  * @param name Name of the command to retrieve
88  * @return Command with the specified name or null if a command with that
89  * label doesn't exist
90  */
91  public Command getCommand(String name);
92 
93 
94  /**
95  * Looks for the requested command and executes an appropriate
96  * tab-completer if found. This method will also tab-complete partial
97  * commands.
98  *
99  * @param sender The command's sender.
100  * @param cmdLine The entire command string to tab-complete, excluding
101  * initial slash.
102  * @return a list of possible tab-completions. This list may be immutable.
103  * Will be null if no matching command of which sender has permission.
104  * @throws CommandException Thrown when the tab-completer for the given
105  * command fails with an unhandled exception
106  * @throws IllegalArgumentException if either sender or cmdLine are null
107  */
108  public List<String> tabComplete(CommandSender sender, String cmdLine) throws IllegalArgumentException;
109 }
List< String > tabComplete(CommandSender sender, String cmdLine)
Command getCommand(String name)
void registerAll(String fallbackPrefix, List< Command > commands)
boolean dispatch(CommandSender sender, String cmdLine)