Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 64 lines 3.0 kB view raw
1package org.bukkit.command; 2 3import java.util.List; 4 5public interface CommandMap { 6 7 /** 8 * Registers all the commands belonging to a certain plugin. 9 * Caller can use:- 10 * command.getName() to determine the label registered for this command 11 * command.getAliases() to determine the aliases which where registered 12 * 13 * @param fallbackPrefix a prefix which is prepended to each command with a ':' one or more times to make the command unique 14 * @param commands a list of commands to register 15 */ 16 public void registerAll(String fallbackPrefix, List<Command> commands); 17 18 /** 19 * Registers a command. Returns true on success; false if name is already taken and fallback had to be used. 20 * Caller can use:- 21 * command.getName() to determine the label registered for this command 22 * command.getAliases() to determine the aliases which where registered 23 * 24 * @param label the label of the command, without the '/'-prefix. 25 * @param fallbackPrefix a prefix which is prepended to the command with a ':' one or more times to make the command unique 26 * @param command the command to register 27 * @return true if command was registered with the passed in label, false otherwise, which indicates the fallbackPrefix was used one or more times 28 */ 29 public boolean register(String label, String fallbackPrefix, Command command); 30 31 /** 32 * Registers a command. Returns true on success; false if name is already taken and fallback had to be used. 33 * Caller can use:- 34 * command.getName() to determine the label registered for this command 35 * command.getAliases() to determine the aliases which where registered 36 * 37 * @param fallbackPrefix a prefix which is prepended to the command with a ':' one or more times to make the command unique 38 * @param command the command to register, from which label is determined from the command name 39 * @return true if command was registered with the passed in label, false otherwise, which indicates the fallbackPrefix was used one or more times 40 */ 41 public boolean register(String fallbackPrefix, Command command); 42 43 /** 44 * Looks for the requested command and executes it if found. 45 * 46 * @param cmdLine command + arguments. Example: "/test abc 123" 47 * @return targetFound returns false if no target is found, true otherwise. 48 * @throws CommandException Thrown when the executor for the given command fails with an unhandled exception 49 */ 50 public boolean dispatch(CommandSender sender, String cmdLine) throws CommandException; 51 52 /** 53 * Clears all registered commands. 54 */ 55 public void clearCommands(); 56 57 /** 58 * Gets the command registered to the specified name 59 * 60 * @param name Name of the command to retrieve 61 * @return Command with the specified name or null if a command with that label doesn't exist 62 */ 63 public Command getCommand(String name); 64}