cmd
Class Alias

java.lang.Object
  extended by cmd.Alias
All Implemented Interfaces:
Command

public class Alias
extends java.lang.Object
implements Command

Alias Creates a new alias. An alias is just another for the user to type a command. For example, "e" instead of "move e".


Constructor Summary
Alias()
           
 
Method Summary
 void addParams(java.lang.String[] newParams)
          Add an array of parameters to the current parameter list
 void construct(java.lang.String[] params)
          construct is called when the Command is created.
 void exec(Player p)
          exec is the main method of the command.
static boolean exists(java.lang.String name)
          Checks to see if an alias exists with selected name
static Alias get(java.lang.String name)
          Get specified alias
 java.lang.String getCommand()
          Get the command that is tied to this alias
 java.lang.String[] getParams()
          Casts the list of params into an array
 void remove()
          Removes current alias
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Alias

public Alias()
Method Detail

exec

public void exec(Player p)
Description copied from interface: Command
exec is the main method of the command. exec is called by executeCommand in the core.Game class. Everything that should happen when you execute the command, besides the initialisation of what the command should execute on, should happen in this method.

Specified by:
exec in interface Command
Parameters:
p - is the main player. The player is passed to exec because a lot of useful info, such as the current room, are attached to the Player class.

construct

public void construct(java.lang.String[] params)
Description copied from interface: Command
construct is called when the Command is created. construct should parse the params array, and get relevant information from it. For example, if the command was "move e", the params array would contain "e", so the construct command should set an instance variable dir that has "e" as its value. Then, when exec is called, it can use this information.

Specified by:
construct in interface Command

get

public static Alias get(java.lang.String name)
Get specified alias

Parameters:
name -
Returns:
alias with name, if found. Null otherwise.

getParams

public java.lang.String[] getParams()
Casts the list of params into an array

Returns:
parameter array

getCommand

public java.lang.String getCommand()
Get the command that is tied to this alias

Returns:
the command associated with current alias

remove

public void remove()
Removes current alias


addParams

public void addParams(java.lang.String[] newParams)
Add an array of parameters to the current parameter list

Parameters:
newParams - New array of parameters to add to the alias

exists

public static boolean exists(java.lang.String name)
Checks to see if an alias exists with selected name

Parameters:
name - alias name to check for
Returns:
true if it exists, false if not

toString

public java.lang.String toString()
Specified by:
toString in interface Command
Overrides:
toString in class java.lang.Object
Returns:
The description of the command created for the Help command to print when the player types "help your_cmd_name".