org.bukkit.command
Class SimpleCommandMap

java.lang.Object
  extended by org.bukkit.command.SimpleCommandMap
All Implemented Interfaces:
CommandMap

public class SimpleCommandMap
extends Object
implements CommandMap


Field Summary
protected  Set<String> aliases
           
protected static Set<VanillaCommand> fallbackCommands
           
protected  Map<String,Command> knownCommands
           
 
Constructor Summary
SimpleCommandMap(Server server)
           
 
Method Summary
 void clearCommands()
          Clears all registered commands.
 boolean dispatch(CommandSender sender, String commandLine)
          Looks for the requested command and executes it if found.
 Command getCommand(String name)
          Gets the command registered to the specified name
 Collection<Command> getCommands()
           
protected  Command getFallback(String label)
           
 Set<VanillaCommand> getFallbackCommands()
           
 boolean register(String fallbackPrefix, Command command)
          Registers a command.
 boolean register(String label, String fallbackPrefix, Command command)
          Registers a command.
 void registerAll(String fallbackPrefix, List<Command> commands)
          Registers all the commands belonging to a certain plugin.
 void registerServerAliases()
           
 List<String> tabComplete(CommandSender sender, String cmdLine)
          Looks for the requested command and executes an appropriate tab-completer if found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

knownCommands

protected final Map<String,Command> knownCommands

aliases

protected final Set<String> aliases

fallbackCommands

protected static final Set<VanillaCommand> fallbackCommands
Constructor Detail

SimpleCommandMap

public SimpleCommandMap(Server server)
Method Detail

registerAll

public void registerAll(String fallbackPrefix,
                        List<Command> commands)
Registers all the commands belonging to a certain plugin. Caller can use:- command.getName() to determine the label registered for this command command.getAliases() to determine the aliases which where registered

Specified by:
registerAll in interface CommandMap
Parameters:
fallbackPrefix - a prefix which is prepended to each command with a ':' one or more times to make the command unique
commands - a list of commands to register

register

public boolean register(String fallbackPrefix,
                        Command command)
Registers a command. Returns true on success; false if name is already taken and fallback had to be used. Caller can use:- command.getName() to determine the label registered for this command command.getAliases() to determine the aliases which where registered

Specified by:
register in interface CommandMap
Parameters:
fallbackPrefix - a prefix which is prepended to the command with a ':' one or more times to make the command unique
command - the command to register, from which label is determined from the command name
Returns:
true if command was registered with the passed in label, false otherwise, which indicates the fallbackPrefix was used one or more times

register

public boolean register(String label,
                        String fallbackPrefix,
                        Command command)
Registers a command. Returns true on success; false if name is already taken and fallback had to be used. Caller can use:- command.getName() to determine the label registered for this command command.getAliases() to determine the aliases which where registered

Specified by:
register in interface CommandMap
Parameters:
label - the label of the command, without the '/'-prefix.
fallbackPrefix - a prefix which is prepended to the command with a ':' one or more times to make the command unique
command - the command to register
Returns:
true if command was registered with the passed in label, false otherwise, which indicates the fallbackPrefix was used one or more times

getFallback

protected Command getFallback(String label)

getFallbackCommands

public Set<VanillaCommand> getFallbackCommands()

dispatch

public boolean dispatch(CommandSender sender,
                        String commandLine)
                 throws CommandException
Looks for the requested command and executes it if found.

Specified by:
dispatch in interface CommandMap
Parameters:
sender - The command's sender
commandLine - command + arguments. Example: "/test abc 123"
Returns:
returns false if no target is found, true otherwise.
Throws:
CommandException - Thrown when the executor for the given command fails with an unhandled exception

clearCommands

public void clearCommands()
Description copied from interface: CommandMap
Clears all registered commands.

Specified by:
clearCommands in interface CommandMap

getCommand

public Command getCommand(String name)
Description copied from interface: CommandMap
Gets the command registered to the specified name

Specified by:
getCommand in interface CommandMap
Parameters:
name - Name of the command to retrieve
Returns:
Command with the specified name or null if a command with that label doesn't exist

tabComplete

public List<String> tabComplete(CommandSender sender,
                                String cmdLine)
Description copied from interface: CommandMap
Looks for the requested command and executes an appropriate tab-completer if found. This method will also tab-complete partial commands.

Specified by:
tabComplete in interface CommandMap
Parameters:
sender - The command's sender.
cmdLine - The entire command string to tab-complete, excluding initial slash.
Returns:
a list of possible tab-completions. This list may be immutable. Will be null if no matching command of which sender has permission.

getCommands

public Collection<Command> getCommands()

registerServerAliases

public void registerServerAliases()


Copyright © 2013. All Rights Reserved.