|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.commands.CommandListImpl
This object stores Commands. All game commands (built-in or add-on) are Commands. A Command registers itself with a particular agent (e.g. player or monster) so that the agent can execute the command implemented by the Command. Upon registering, the Command is stored in a table managed by this class.
Command
Nested Class Summary |
Nested classes inherited from class wyvern.lib.CommandList |
CommandList.CommandFilter |
Field Summary | |
protected AtmosphereCommands |
atmospheres_
|
static java.lang.Class[] |
builtins
All the built-in game commands must go in this list. |
protected wyvern.kernel.data.MultiHashMap |
commands_
|
protected java.util.ArrayList |
filters_
The list of objects requesting to get a chance to handle each command as it comes through. |
protected Commandable |
owner_
A reference to the Player this list is associated with, if any. |
static java.lang.Class[] |
wiz_builtins
|
Constructor Summary | |
CommandListImpl()
Creates a CommandListImpl with a set of built-in commands. |
|
CommandListImpl(Commandable c)
Constructs a new CommandListImpl for the specified Player. |
Method Summary | |
protected void |
addBuiltIn(java.lang.Class handler)
Adds a built-in command Singleton to the list. |
void |
addBuiltInCommands()
Put the default game commands into the dictionary. |
void |
addFilter(CommandList.CommandFilter obj)
Adds a filter object (a Command wanting to get the opportunity to handle all commands that come through) to the list. |
void |
addWizBuiltins()
Put built-in commands just for Wizards into the dictionary. |
protected Command |
askFilters(java.lang.String cmd)
Asks the filter objects if they want to handle the command. |
protected boolean |
commandKnown(Command ex,
CommandEvent event)
Returns true if the command was enqueued by the game engine, OR if it was enqueued by a user and the user is allowed to execute this command. |
void |
destroy()
Nukes all the internal structures, for the garbage collector. |
Command |
findHandler(CommandEvent event)
Finds an object to handle the specified command. |
Commandable |
getCommandable()
Returns the Commandable (usually a Player) that this list is associated with. |
java.util.Map |
getCommandMap()
Returns the MultiHashMap mapping commands to handlers. |
java.lang.String[] |
getCommands()
Returns a list of all the commands in this list. |
Command[] |
getRegisteredCommands(java.lang.String verb)
Returns the registered commands for the given Command handler. |
void |
registerCommand(java.lang.String command,
Command handler)
Registers a new command command. |
void |
reload()
Reloads all the built-in command handlers. |
void |
removeFilter(CommandList.CommandFilter obj)
Called by a Command when it wants to get off the list for being requested about handling every command. |
void |
unregisterCommand(java.lang.String command,
Command handler)
Unregisters a command. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.Class[] builtins
public static final java.lang.Class[] wiz_builtins
protected transient wyvern.kernel.data.MultiHashMap commands_
protected transient AtmosphereCommands atmospheres_
protected transient java.util.ArrayList filters_
protected Commandable owner_
Constructor Detail |
public CommandListImpl()
public CommandListImpl(Commandable c)
c
- the Commandable (more flexibility than a Player,
just in case we need it) the list is being created for.Method Detail |
public void reload()
CommandList
reload
in interface CommandList
public void addBuiltInCommands()
public void addWizBuiltins()
CommandList
addWizBuiltins
in interface CommandList
protected void addBuiltIn(java.lang.Class handler)
handler
- a built-in command to add to the listpublic void addFilter(CommandList.CommandFilter obj)
CommandList
addFilter
in interface CommandList
obj
- a filterpublic void removeFilter(CommandList.CommandFilter obj)
CommandList
removeFilter
in interface CommandList
obj
- the filter to removepublic Command findHandler(CommandEvent event)
CommandList
findHandler
in interface CommandList
event
- the CommandEvent containing the command
protected boolean commandKnown(Command ex, CommandEvent event)
ex
- the Command handling the command (will implement
a special interface if it's off-limits to players).event
- the event encapsulating the command & argsprotected Command askFilters(java.lang.String cmd)
cmd
- the command
public void registerCommand(java.lang.String command, Command handler)
CommandList
The new command will go at the front of the list of handlers for the command. I.e. the most recently-added command gets first shot at the command.
registerCommand
in interface CommandList
command
- the command verb to registerhandler
- the Command object that implements the commandpublic void unregisterCommand(java.lang.String command, Command handler)
CommandList
unregisterCommand
in interface CommandList
command
- the command verb to registerhandler
- the Command object that implements the commandpublic Commandable getCommandable()
CommandList
getCommandable
in interface CommandList
public java.lang.String[] getCommands()
CommandList
getCommands
in interface CommandList
public java.util.Map getCommandMap()
CommandList
getCommandMap
in interface CommandList
public Command[] getRegisteredCommands(java.lang.String verb)
CommandList
getRegisteredCommands
in interface CommandList
verb
- a command verb
public void destroy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |