wyvern.kernel.player
Class ClientCommands

java.lang.Object
  extended bywyvern.kernel.player.ClientCommands
All Implemented Interfaces:
BuiltInCommand, Command, RPCConstants

public final class ClientCommands
extends java.lang.Object
implements BuiltInCommand, RPCConstants

Handles special commands from the client. Each Player gets one of these, which can be accessed via the player's clientCommands() method. The client sends various commands to the server that start with "#". If you want to be notified when one of these commands is sent, you register with the ClientCommands to be notified for a particular set of client commands.

Version:
1.0, Jul 23, 2003
Author:
Steve Yegge

Nested Class Summary
 
Nested classes inherited from class wyvern.common.net.RPCConstants
RPCConstants.ImageAlign, RPCConstants.ImageFlags, RPCConstants.ImageFormat, RPCConstants.OutputView, RPCConstants.TextStyle
 
Field Summary
 
Fields inherited from interface wyvern.common.net.RPCConstants
ALERT_EVENT, CHAR_BANISHED, CHAR_BANNED, CHARACTER_NOT_FOUND, CLIENT_END_MUSIC_COMMAND, CLIENT_END_SOUND_COMMAND, CONNECT_RESULT, FLUSH_GRAPHICS, GND_ADD, GND_MODIFY, GND_REMOVE, GND_RESEND, INV_ADD, INV_MODIFY, INV_REMOVE, INV_RESEND, INVALID_PASSWORD, IP_BANISHED, LOGIN_FAILURE, LOGIN_SUCCESS, LOGINS_DISABLED, MAX_IMAGE_SIZE, MUSIC_EVENT, OTHER_LOGIN_ERROR, PAUSE_SOUND, PLAY_ALERT, PLAY_MUSIC, PLAY_SOUND, PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR, QUIT, REGISTER_EXISTING_PLAYER, RESUME_SOUND, SAME_EMAIL_ONLINE, SEND_FILE, SEND_IMAGE, SEND_PICTURE, SEND_TILE, SEND_TILE_MAPPINGS, SERVER_TRANSFER, SET_GAIN, SOUND_EVENT, STAT_SEND_SPELLS, STAT_SET_FOOD, STAT_SET_GOLD, STAT_SET_HP, STAT_SET_LEVEL, STAT_SET_LOAD, STAT_SET_NAME, STAT_SET_RANGE, STAT_SET_SP, STAT_SET_XP, STAT_START_POISON, STAT_STOP_POISON, STAT_UPDATE_ALL, STOP_ALL_SOUNDS, STOP_MUSIC, STOP_SOUND, TEXT_OUT, TOO_MANY_PLAYERS, UNCACHE_IMAGE, XML_COMMAND, XML_COMMAND_WITH_COMPRESSED_DATA, XML_COMMAND_WITH_DATA, ZIP_PARTIAL_SCREEN, ZIP_SCREEN, ZIP_TEXT_OUT
 
Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Adds commands.
 CommandEvent createEvent(CommandEvent event)
          Creates the event.
 boolean execute(CommandEvent event)
          Executes the event containing a client directive.
static ClientCommands getImpl()
           
 boolean knowsCommand(java.lang.String command)
          Returns true if we want to handle the specified command.
 boolean refresh(CommandEvent event)
          Refreshes the player's screen - usually not necessary, but used (e.g.) when toggling terrain borders, or when a new image has arrived on the client.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getImpl

public static ClientCommands getImpl()

addCommands

public final void addCommands(java.util.Map commands,
                              CommandList list)
Adds commands.

Specified by:
addCommands in interface BuiltInCommand
Parameters:
commands - the java.util.Map to register with
list - the CommandList the Command is being added to.

knowsCommand

public boolean knowsCommand(java.lang.String command)
Returns true if we want to handle the specified command.

Specified by:
knowsCommand in interface Command
Parameters:
command - the entire command string, including arguments
Returns:
true if we want to handle the command

createEvent

public CommandEvent createEvent(CommandEvent event)
Creates the event.

Specified by:
createEvent in interface Command
Parameters:
event - a "blank" CommandEvent containing only the command text and the agent who's performing the command. This initial event is created by the originator of the event (e.g. the AI or player's command preprocessor).
Returns:
a CommandEvent subclass encapsulating this command's execution parameters and state. It should copy in the fields from the passed-in event.

execute

public boolean execute(CommandEvent event)
Executes the event containing a client directive. These events cannot be vetoed, although you could, in theory, change the command verb and arguments. But you shouldn't.

Specified by:
execute in interface Command
Parameters:
event - the event containing the parsed directive (verb + args)
Returns:
true - always returns true, since the failedPostHook doesn't seem like it would be useful for client directives that the player doesn't know anything about.

refresh

public boolean refresh(CommandEvent event)
Refreshes the player's screen - usually not necessary, but used (e.g.) when toggling terrain borders, or when a new image has arrived on the client.

Parameters:
event - the event

toString

public java.lang.String toString()