wyvern.lib.commands
Class LastCommand

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.commands.SimpleHandler
          extended bywyvern.lib.commands.LastCommand
All Implemented Interfaces:
BuiltInCommand, Command, PropertyList

public class LastCommand
extends SimpleHandler

Shows last shouts, tells, wiz-tells, etc.

Version:
1.0, Apr 02, 2003
Author:
Steve Yegge

Field Summary
static int DEFAULT_MESSAGES
           
static int MAX_MESSAGES
           
 
Fields inherited from class wyvern.kernel.commands.SimpleHandler
delay_
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Adds commands.
static LastCommand getImpl()
           
static byte getTextColor(java.lang.String type)
          Returns the RPCConstants.TextStyle to use for the given message type.
 boolean handleEvent(CommandEvent event)
          Handles the command.
 java.util.List last(Commandable agent, java.lang.String type, int num)
          Gets the last N messages of the given type that the agent heard.
 boolean lastShouts(CommandEvent event, int num)
          Prints the last N shouts to the specified agent.
static void record(java.util.List names, java.lang.String type, java.lang.String msg)
          Records the last message a set of players heard.
 
Methods inherited from class wyvern.kernel.commands.SimpleHandler
createEvent, execute, knowsCommand
 
Methods inherited from class wyvern.kernel.properties.PList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, toString, transientlyRemoveProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MESSAGES

public static final int DEFAULT_MESSAGES
See Also:
Constant Field Values

MAX_MESSAGES

public static final int MAX_MESSAGES
See Also:
Constant Field Values
Method Detail

getImpl

public static LastCommand getImpl()

addCommands

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

Specified by:
addCommands in interface BuiltInCommand
Specified by:
addCommands in class SimpleHandler
Parameters:
list - the CommandList we're associating with, if any
commands - the map to place our commands in.

handleEvent

public boolean handleEvent(CommandEvent event)
Handles the command.

Specified by:
handleEvent in class SimpleHandler
Parameters:
event - a CommandEvent with various fields filled in: the agent performing the command, the command verb and arguments, the delay for the command, and success/failure messages.
Returns:
true if it was completed successfully

lastShouts

public boolean lastShouts(CommandEvent event,
                          int num)
Prints the last N shouts to the specified agent.


record

public static void record(java.util.List names,
                          java.lang.String type,
                          java.lang.String msg)
Records the last message a set of players heard.

Parameters:
names - a (possibly null) list of names of players who heard the message.
type - the message type: "say", "tell", "wiz", "magetell", etc.
msg - the message, e.g. "Rhialto says: hi!"

last

public java.util.List last(Commandable agent,
                           java.lang.String type,
                           int num)
Gets the last N messages of the given type that the agent heard.

Parameters:
agent - the player to check
type - the message type
num - the max number to retrieve
Returns:
a list of matching messages, sorted by time. List can be empty if player hasn't heard any of that type in this session. Message returned have type prepended in parentheses, e.g. "(wiz) rhialto wiz-tells: testing", so you can figure out which color to send based on the message type.

getTextColor

public static byte getTextColor(java.lang.String type)
Returns the RPCConstants.TextStyle to use for the given message type.

Parameters:
type - a message type, such as "wiz", "tell", or "magetell".
Returns:
an RPCConstants.TextStyle constant to pass through to the client, for coloring the message. Defaults to plain/black if it doesn't know what kind of message it is.