wyvern.kernel.player
Class Snooper

java.lang.Object
  extended bywyvern.kernel.player.Snooper
All Implemented Interfaces:
java.util.EventListener, MapChangeListener, MapMotionListener, MessageListener, MotionTracker, Subscriber

public class Snooper
extends java.lang.Object
implements MotionTracker, MessageListener, Subscriber

Sets up snooping, in which a player can view another player or other Commandable.

To use a Snooper: - make sure the player isn't already snooping someone

Version:
1.0, Oct 30, 2003
Author:
Steve Yegge

Field Summary
protected  Player snooper_
           
protected  java.lang.String snoopType_
           
protected  long start_
           
protected  Commandable target_
           
 
Constructor Summary
Snooper(Player snooper, Commandable target)
          Constructs a new Snooper.
 
Method Summary
protected  void addListeners()
          Sets up listeners on the target for map movement, messages, and leaving the game.
 void destroy()
          Turns off the snooper.
 void disableMessageDisplay()
          Turns text-message snooping off.
 void disableViewerMovement()
          Sets policy of turning off snooping automatically if the viewer moves.
 void enableMessageDisplay()
          Turns text-message snooping on.
 void enableViewerMovement()
          Allows agent to move while snooping the target.
 Player getSnooper()
          Returns the wizard doing the snooping.
 java.lang.String getSnoopType()
          Returns the type of snooping going on, e.g.
 Commandable getTarget()
          Returns the player currently being snooped.
 boolean isMessageDisplayEnabled()
          Returns true if text-message snooping is currently enabled.
 boolean isViewerMoveEnabled()
          Returns true if the agent can move without automatically discontinuing snooping.
 void messageReceived(MessageEvent event)
          A player we're tracking received a message.
 void pubsubMessage(Message message)
          A player quit.
protected  void restoreCamera()
          Returns control of the camera to the viewer.
 void setSnoopType(java.lang.String type)
          Sets the type of snooping.
 void start()
          Starts the snooping, and stuffs a reference to this Snooper object in a property on the agent called "@snooper".
 void targetEnteredMap(MapChangeEvent event)
          Viewer or viewee entered a map.
 void targetLeftMap(MapChangeEvent event)
          Viewer or viewee left a map.
 void targetMoved(MapMotionEvent event)
          Viewer or viewee moved in map.
 void vieweeMoved(Player p)
          Viewed player moved.
 void viewerMoved()
          Viewing player moved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

snooper_

protected Player snooper_

target_

protected Commandable target_

snoopType_

protected java.lang.String snoopType_

start_

protected long start_
Constructor Detail

Snooper

public Snooper(Player snooper,
               Commandable target)
Constructs a new Snooper. Note: snooping is logged.

Parameters:
snooper - the player doing the snooping
target - the player to snoop
Method Detail

start

public void start()
Starts the snooping, and stuffs a reference to this Snooper object in a property on the agent called "@snooper". You can turn it off by calling destroy() on the Snooper.

Throws:
java.lang.IllegalStateException - if the agent is already snooping someone, or if this Snooper object has been destroyed.

addListeners

protected void addListeners()
Sets up listeners on the target for map movement, messages, and leaving the game.


enableMessageDisplay

public void enableMessageDisplay()
Turns text-message snooping on.


disableMessageDisplay

public void disableMessageDisplay()
Turns text-message snooping off.


isMessageDisplayEnabled

public boolean isMessageDisplayEnabled()
Returns true if text-message snooping is currently enabled.


enableViewerMovement

public void enableViewerMovement()
Allows agent to move while snooping the target.


disableViewerMovement

public void disableViewerMovement()
Sets policy of turning off snooping automatically if the viewer moves.


isViewerMoveEnabled

public boolean isViewerMoveEnabled()
Returns true if the agent can move without automatically discontinuing snooping.


getTarget

public Commandable getTarget()
Returns the player currently being snooped.


getSnooper

public Player getSnooper()
Returns the wizard doing the snooping.


getSnoopType

public java.lang.String getSnoopType()
Returns the type of snooping going on, e.g. "crystal ball", or "wiz snoop".


setSnoopType

public void setSnoopType(java.lang.String type)
Sets the type of snooping.

Parameters:
type - a type to put in the logs

targetEnteredMap

public void targetEnteredMap(MapChangeEvent event)
Viewer or viewee entered a map.

Specified by:
targetEnteredMap in interface MapChangeListener

targetLeftMap

public void targetLeftMap(MapChangeEvent event)
Viewer or viewee left a map.

Specified by:
targetLeftMap in interface MapChangeListener

targetMoved

public void targetMoved(MapMotionEvent event)
Viewer or viewee moved in map.

Specified by:
targetMoved in interface MapMotionListener

vieweeMoved

public void vieweeMoved(Player p)
Viewed player moved. Update camera to point to them.

Parameters:
p - the player who moved

viewerMoved

public void viewerMoved()
Viewing player moved. Stop viewing.


messageReceived

public void messageReceived(MessageEvent event)
A player we're tracking received a message.

Specified by:
messageReceived in interface MessageListener
Parameters:
event - a MessageEvent saying who got the message, and what it was

pubsubMessage

public void pubsubMessage(Message message)
A player quit. If it's ours, turn snooping off.

Specified by:
pubsubMessage in interface Subscriber
Parameters:
message - the message

restoreCamera

protected void restoreCamera()
Returns control of the camera to the viewer.


destroy

public void destroy()
Turns off the snooper. Issues no messages.