|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.player.CommandPreprocessor
Takes incoming commands and decides what to do with them. Commands can come from the client, or the server can place the commands in the player's queue.
This class handles alias and multi-command expansion, command history expansion and substitution, command tracking, updating the idle timer, and other activities associated with preprocessing player commands.
Field Summary | |
static int |
COMMAND_HISTORY_LENGTH
Number of commands we'll store in the command history. |
Constructor Summary | |
CommandPreprocessor(Player player)
Constructs a new CommandPreprocessor |
Method Summary | |
protected void |
addToHistoryList(java.lang.String cmd)
Adds a command to the player's history list, so it can be retrieved or examined later. |
protected void |
doEventTracking(java.lang.String cmd,
boolean user)
Logs a player's command if we're tracking them. |
protected java.lang.String |
expandAlias(java.lang.String cmd,
java.lang.String verb,
java.lang.String args)
Looks at the command verb for the passed command, and does alias expansion. |
java.lang.String |
findLastMatchingCommand(java.lang.String prefix)
Looks through the history list to find the most recent command that starts with the passed prefix. |
void |
handleCommand(java.lang.String cmd,
boolean user)
Deals with a command coming in to the player via the command() method. |
protected boolean |
handleControlCommand(java.lang.String cmd)
Handles some special control characters for doing history substitution. |
protected void |
handleMacroCommand(java.lang.String cmd,
boolean user)
Splits a multiple-command macro into its sub-commands and enqueues them with the player. |
protected void |
handleNonMacroCommand(java.lang.String cmd,
boolean user)
Handles enqueueing a command string that's not going to be parsed as a multiple-command macro. |
protected void |
initNoMacroList()
Initializes the list of command verbs that we don't allow to appear in multi-command macros. |
protected void |
processCommand(java.lang.String cmd,
boolean user)
Processes a command without doing "!" |
protected boolean |
tryHistoryExpansion(java.lang.String cmd)
Checks if the command starts with "!" |
protected boolean |
tryHistorySubstitution(java.lang.String cmd)
Attempts to perform a history-substitution on the previous command. |
void |
updateHistory(java.lang.String cmd)
Adds the most recent command to the player's history list. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int COMMAND_HISTORY_LENGTH
Constructor Detail |
public CommandPreprocessor(Player player)
Method Detail |
public void handleCommand(java.lang.String cmd, boolean user)
cmd
- a command stringuser
- true if the command was player-initiated (i.e.
it came from the client.)protected void processCommand(java.lang.String cmd, boolean user)
cmd
- a command stringuser
- true if the command was player-initiated (i.e.
it came from the client.)protected java.lang.String expandAlias(java.lang.String cmd, java.lang.String verb, java.lang.String args)
cmd
- the command the player typedverb
- the first whitespace-delimited token of the commandargs
- the remainder of the command after the verb, or
null if there were no args
protected void handleNonMacroCommand(java.lang.String cmd, boolean user)
cmd
- the command stringuser
- true if player-initiatedprotected void handleMacroCommand(java.lang.String cmd, boolean user)
cmd
- the command to splituser
- true if user-initiatedprotected void doEventTracking(java.lang.String cmd, boolean user)
cmd
- a command going into the player's queueuser
- true if it's user-initiatedpublic void updateHistory(java.lang.String cmd)
cmd
- the command to add to the history list
protected void addToHistoryList(java.lang.String cmd)
You should store commands in this list in pre-expanded form; for example, if the user types "foo bag" (an alias for something), then "!foo" should retrieve the "foo bag" command, not what it expanded into.
cmd
- the command to add.protected boolean handleControlCommand(java.lang.String cmd)
cmd
- the command the player typed
protected boolean tryHistoryExpansion(java.lang.String cmd)
cmd
- a command the player typed in
protected boolean tryHistorySubstitution(java.lang.String cmd)
cmd
- the command the user typed
public java.lang.String findLastMatchingCommand(java.lang.String prefix)
prefix
- the beginning of a command to match
protected void initNoMacroList()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |