wyvern.lib.commands
Class ShoutCommand

java.lang.Object
  extended bywyvern.lib.commands.ShoutCommand
All Implemented Interfaces:
BuiltInCommand, Command

public class ShoutCommand
extends java.lang.Object
implements BuiltInCommand

Sends a message to every player on the game. Handles chat channels as well.

Version:
1.0, Jan 23, 1998
Author:
Steve Yegge

Field Summary
static java.lang.String MYCLASS
           
static int NAUGHTY_SHOUT_MINUTES
          How long to auto-silence players who shout the f-word.
static int THIRTY_MINUTES
           
 
Method Summary
 void addCommands(java.util.Map commands, CommandList list)
          Tells the Command to add the commands that it wants to implement into the passed data structure.
static boolean checkSilenced(CommandEvent event)
          Returns true if agent is silenced.
 CommandEvent createEvent(CommandEvent initialInfo)
          Creates a CommandEvent that encapsulates all the state necessary to perform the command.
 boolean execute(CommandEvent e)
          Executes the specified CommandEvent.
static ShoutCommand getImpl()
           
static java.util.List getLastShouts()
          Returns the last 100 or so shouts.
static int getRequiredShoutPoints(java.lang.String msg)
          Returns the number of shout points this agent needs to shout something, based on the agent's skills, the current player count online, and the text of the shout.
static java.lang.String getSilencer(Player player)
          Returns the name of the wizard or agent who silenced the player.
static java.lang.String getSilenceReason(Player agent)
          Returns the reason the player is silenced, if they're silenced.
static int getSilenceTime(Player agent)
          Returns the number of minutes of silence the player has remaining.
static java.util.List getValidChannels()
          Returns the chat channels we currently support.
static boolean isPlayerSubscribed(Player p, java.lang.String channel)
          Returns true if the passed player is subscribed to the specified channel.
static boolean isSilenced(Player p)
          Returns true if agent is silenced.
static boolean isSilencedNotifyPlayer(Player p)
          Same as isSilenced(), but tells the player who silenced them, why, and how many more minutes of silence remain.
 boolean knowsCommand(java.lang.String command)
          Returns true if this Command wants to handle the command.
static void putInLastShoutList(java.lang.String msg)
          Adds a message to the last-shout list.
static void shoutToAllPlayers(Commandable shouter, java.lang.String msg, boolean isChannel, java.lang.String verb)
          Shouts a message to all the players on the game, skipping any with earmuffs, or who are ignoring the agent, or whatever.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MYCLASS

public static final java.lang.String MYCLASS
See Also:
Constant Field Values

NAUGHTY_SHOUT_MINUTES

public static final int NAUGHTY_SHOUT_MINUTES
How long to auto-silence players who shout the f-word.

See Also:
Constant Field Values

THIRTY_MINUTES

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

getImpl

public static ShoutCommand getImpl()

addCommands

public void addCommands(java.util.Map commands,
                        CommandList list)
Description copied from interface: BuiltInCommand
Tells the Command to add the commands that it wants to implement into the passed data structure.

Specified by:
addCommands in interface BuiltInCommand
Parameters:
commands - a Map whose keys are commands, and whose values are Commands that handle those commands.
list - the CommandList the Command is being added to.

knowsCommand

public boolean knowsCommand(java.lang.String command)
Description copied from interface: Command
Returns true if this Command wants to handle the command. The Command can examine the arguments and determine that it doesn't actually understand the command, in which case it should return false.

This method exists to allow more than one game object to implement the same command verb, but with different expected arguments.

If two objects register for the same command and the same arguments, the object that was registered most recently gets to handle at the 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 initialInfo)
Description copied from interface: Command
Creates a CommandEvent that encapsulates all the state necessary to perform the command. A well-designed CommandEvent exposes all of its "properties" so that hook objects can modify its behavior. For instance, many commands result in some sort of message being sent back to the client. The message should be among the properties that hooks can override.

This method is called by the kernel. The kernel passes the event to the pre-hook, then calls Command.execute() (below) to execute the event, and finally calls the post-hook.

Specified by:
createEvent in interface Command
Parameters:
initialInfo - 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 e)
Description copied from interface: Command
Executes the specified CommandEvent. The CommandEvent contains all the parameters and state required to execute the command; the parameters have been filtered through hook objects, so they may not be the same as when the event was created.

Specified by:
execute in interface Command
Parameters:
e - the CommandEvent to execute
Returns:
true if the event completed successfully, else false.

getValidChannels

public static java.util.List getValidChannels()
Returns the chat channels we currently support.

Returns:
a list of channel names

isPlayerSubscribed

public static boolean isPlayerSubscribed(Player p,
                                         java.lang.String channel)
Returns true if the passed player is subscribed to the specified channel.


putInLastShoutList

public static void putInLastShoutList(java.lang.String msg)
Adds a message to the last-shout list.


getLastShouts

public static java.util.List getLastShouts()
Returns the last 100 or so shouts. The list is ordered from most recent to least recent.


checkSilenced

public static boolean checkSilenced(CommandEvent event)
Returns true if agent is silenced. If so, vetoes the event with a suitable message, telling them how long they'll be silenced.

Parameters:
event - the ShoutEvent to veto
Returns:
true if they've been silenced (calls isSilenced()), or false if they're not silenced (or no longer silenced).

getSilenceTime

public static int getSilenceTime(Player agent)
Returns the number of minutes of silence the player has remaining. Note: this calls isSilenced(), which will update the timer, removing the "silenced" properties if the player is no longer silenced.

Returns:
the number of minutes of silence left on their sentence, or 0 if they're not currently silenced.

getSilencer

public static java.lang.String getSilencer(Player player)
Returns the name of the wizard or agent who silenced the player. Stored in a "silenced-by" string property on the player. Note: this method does not call isSilenced(), so it doesn't update the silence timer on the player.

Parameters:
player - the player who's (maybe) silenced
Returns:
the wiz name, or null if the player is not silenced.

getSilenceReason

public static java.lang.String getSilenceReason(Player agent)
Returns the reason the player is silenced, if they're silenced. Note: this method does not call isSilenced(), so it doesn't update the silence timer on the player.

Parameters:
agent - the player who's (maybe) silenced
Returns:
the reason the wiz gave for silencing the player, or null if they're not currently silenced

isSilenced

public static boolean isSilenced(Player p)
Returns true if agent is silenced. Updates the timer.

Returns:
false if they're not silenced. If true, updates the timer. If their silence has expired, removes the property.

isSilencedNotifyPlayer

public static boolean isSilencedNotifyPlayer(Player p)
Same as isSilenced(), but tells the player who silenced them, why, and how many more minutes of silence remain.

Parameters:
p - the player
Returns:
true if the player is silenced. Messages the player.

shoutToAllPlayers

public static void shoutToAllPlayers(Commandable shouter,
                                     java.lang.String msg,
                                     boolean isChannel,
                                     java.lang.String verb)
Shouts a message to all the players on the game, skipping any with earmuffs, or who are ignoring the agent, or whatever.

Parameters:
shouter - the person shouting
msg - the message, e.g. "Rhialto shouts: hi all!"
isChannel - true if it's a chat-channel message (not shout or emergency)
verb - the verb used to shout ("shout", "ooc", etc.)

getRequiredShoutPoints

public static int getRequiredShoutPoints(java.lang.String msg)
Returns the number of shout points this agent needs to shout something, based on the agent's skills, the current player count online, and the text of the shout.

Parameters:
msg - the message they're shouting
Returns:
the number of points it'll cost