Crossfire JXClient, Trunk  R20561
com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess Class Reference

Default implementation for ScriptProcesses. More...

+ Inheritance diagram for com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess:
+ Collaboration diagram for com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess:

Public Member Functions

void addScriptProcessListener (@NotNull final ScriptProcessListener scriptProcessListener)
 Adds a ScriptProcessListener to be notified.
Parameters
scriptProcessListenerthe listener to add
More...
 
void commandSent (@NotNull final String cmd)
 Sends a message to the script process.
Parameters
cmdthe message to send
More...
 
int compareTo (@NotNull final ScriptProcess o)
 
 DefaultScriptProcess (final int scriptId, @NotNull final String filename, @NotNull final CommandQueue commandQueue, @NotNull final CrossfireServerConnection crossfireServerConnection, @NotNull final Stats stats, @NotNull final FloorView floorView, @NotNull final ItemSet itemSet, @NotNull final Iterable< Spell > spellsManager, @NotNull final MapUpdaterState mapUpdaterState, @NotNull final SkillSet skillSet) throws IOException
 Creates a new instance. More...
 
boolean equals (@Nullable final Object obj)
 
String getFilename ()
 Returns the script's filename.
Returns
the script's filename
More...
 
int getScriptId ()
 Returns the script ID identifying this script instance.
Returns
the script ID
More...
 
int hashCode ()
 
void killScript ()
 Kills the script process.Does nothing if the process is not running. More...
 
void run ()
 
String toString ()
 

Private Member Functions

void cmdDraw (@NotNull final String params)
 Processes a "draw" command from the script process. More...
 
void cmdIssue (@NotNull final String params)
 Processes a regular "issue" command from the script process. More...
 
void cmdIssueLock (@NotNull final String params)
 Processes a "issue lock" command from the script process. More...
 
void cmdIssueMark (@NotNull final String params)
 Processes a "issue mark" command from the script process. More...
 
void cmdMonitor ()
 Processes a "monitor" command from the script process. More...
 
void cmdRequest (@NotNull final String params)
 Processes a "request" command from the script process. More...
 
void cmdUnmonitor ()
 Processes an "unmonitor" command from the script process. More...
 
void commandSentItem (@NotNull final String cmd, @NotNull final CfItem item)
 Sends an item info message to the script process. More...
 
void commandSentMap (@NotNull final CfMap map, final int x, final int y)
 Sends info about one map cell to the script process. More...
 
void reportError (@NotNull final String string)
 Reports an error while executing client commands. More...
 
void runScriptCommand (@NotNull final String cmdLine)
 Processes a line received from the script process. More...
 

Private Attributes

final ClientSocketListener clientSocketListener
 The ClientSocketListener attached to crossfireServerConnection to track commands sent to the server. More...
 
final CommandQueue commandQueue
 The CommandQueue for sending commands. More...
 
final CrossfireServerConnection crossfireServerConnection
 The connection instance. More...
 
final String filename
 The script command including arguments. More...
 
final FloorView floorView
 The FloorView to use. More...
 
final InputStream in
 The InputStream of process. More...
 
boolean isMonitoring
 Whether a "monitor" command is active. More...
 
final ItemSet itemSet
 The ItemSet instance to use. More...
 
boolean killed
 Whether this script has been killed. More...
 
final MapUpdaterState mapUpdaterState
 The MapUpdaterState instance to use. More...
 
final OutputStreamWriter osw
 The OutputStreamWriter associated with process. More...
 
final PacketWatcher packetWatcher
 The PacketWatcher to process "watch" commands. More...
 
final Process process
 The Process instance for the executed child process. More...
 
final int scriptId
 The script ID identifying this script instance. More...
 
final EventListenerList2< ScriptProcessListenerscriptProcessListeners = new EventListenerList2<>()
 The ScriptProcessListeners to notify. More...
 
final SkillSet skillSet
 The SkillSet for looking up skill names. More...
 
final Iterable< SpellspellsManager
 The SpellsManager instance to use. More...
 
final Stats stats
 The Stats instance to watch. More...
 

Detailed Description

Default implementation for ScriptProcesses.

Author
Lauwenmark
Andreas Kirschbaum

Definition at line 56 of file DefaultScriptProcess.java.

Constructor & Destructor Documentation

◆ DefaultScriptProcess()

com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.DefaultScriptProcess ( final int  scriptId,
@NotNull final String  filename,
@NotNull final CommandQueue  commandQueue,
@NotNull final CrossfireServerConnection  crossfireServerConnection,
@NotNull final Stats  stats,
@NotNull final FloorView  floorView,
@NotNull final ItemSet  itemSet,
@NotNull final Iterable< Spell spellsManager,
@NotNull final MapUpdaterState  mapUpdaterState,
@NotNull final SkillSet  skillSet 
) throws IOException

Creates a new instance.

Parameters
scriptIdthe script ID identifying the new script
filenamethe command including arguments to execute
commandQueuethe command queue for sending commands
crossfireServerConnectionthe server connection
statsthe stats instance to watch
floorViewthe floor view to use
itemSetthe item set instance to use
spellsManagerthe spells manager instance to use
mapUpdaterStatethe map updater state instance to use
skillSetthe skill set for looking up skill names
Exceptions
IOExceptionif the script cannot be created

Definition at line 216 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandQueue, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.crossfireServerConnection, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.filename, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.floorView, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.itemSet, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.mapUpdaterState, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.scriptId, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.skillSet, com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.spellsManager, and com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.stats.

Member Function Documentation

◆ addScriptProcessListener()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.addScriptProcessListener ( @NotNull final ScriptProcessListener  scriptProcessListener)

Adds a ScriptProcessListener to be notified.

Parameters
scriptProcessListenerthe listener to add

Implements com.realtime.crossfire.jxclient.scripts.ScriptProcess.

Definition at line 725 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.util.EventListenerList2< T extends EventListener >.add().

Referenced by com.realtime.crossfire.jxclient.scripts.ScriptManager.newScript().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmdDraw()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdDraw ( @NotNull final String  params)
private

Processes a "draw" command from the script process.

Parameters
paramsthe command arguments

Definition at line 606 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.drawInfo(), and com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.reportError().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.runScriptCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmdIssue()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdIssue ( @NotNull final String  params)
private

Processes a regular "issue" command from the script process.

Parameters
paramsthe command arguments

Definition at line 578 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.reportError(), and com.realtime.crossfire.jxclient.queue.CommandQueue.sendNcom().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.runScriptCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmdIssueLock()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdIssueLock ( @NotNull final String  params)
private

Processes a "issue lock" command from the script process.

Parameters
paramsthe command arguments

Definition at line 552 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.reportError(), and com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.sendLock().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.runScriptCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmdIssueMark()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdIssueMark ( @NotNull final String  params)
private

Processes a "issue mark" command from the script process.

Parameters
paramsthe command arguments

Definition at line 537 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.reportError(), and com.realtime.crossfire.jxclient.server.crossfire.CrossfireServerConnection.sendMark().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.runScriptCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmdMonitor()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdMonitor ( )
private

Processes a "monitor" command from the script process.

Definition at line 625 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.server.server.ServerConnection.addClientSocketListener().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.runScriptCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmdRequest()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdRequest ( @NotNull final String  params)
private

Processes a "request" command from the script process.

Parameters
paramsthe command arguments

Definition at line 398 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.queue.CommandQueue.checkFire(), com.realtime.crossfire.jxclient.queue.CommandQueue.checkRun(), com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSent(), com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSentItem(), com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSentMap(), com.realtime.crossfire.jxclient.stats.Stats.CS_NUM_SKILLS, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_AC, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_APPLIED_CHA, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_APPLIED_CON, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_APPLIED_DEX, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_APPLIED_INT, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_APPLIED_POW, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_APPLIED_STR, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_APPLIED_WIS, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_BASE_CHA, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_BASE_CON, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_BASE_DEX, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_BASE_INT, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_BASE_POW, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_BASE_STR, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_BASE_WIS, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_CHA, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_CON, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_DAM, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_DEX, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_FLAGS, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_FOOD, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_GRACE, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_HP, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_INT, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_LEVEL, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_MAXGRACE, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_MAXHP, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_MAXSP, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_POW, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RACE_CHA, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RACE_CON, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RACE_DEX, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RACE_INT, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RACE_POW, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RACE_STR, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RACE_WIS, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RESIST_END, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_RESIST_START, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_SKILLINFO, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_SP, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_SPEED, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_SPELL_ATTUNE, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_SPELL_DENY, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_SPELL_REPEL, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_STR, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_WC, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_WEAP_SP, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_WEIGHT_LIM, com.realtime.crossfire.jxclient.stats.Stats.CS_STAT_WIS, com.realtime.crossfire.jxclient.items.FloorView.getCurrentFloor(), com.realtime.crossfire.jxclient.skills.Skill.getExperience(), com.realtime.crossfire.jxclient.stats.Stats.getExperience(), com.realtime.crossfire.jxclient.items.ItemSet.getItemsByLocation(), com.realtime.crossfire.jxclient.skills.Skill.getLevel(), com.realtime.crossfire.jxclient.map.MapUpdaterState.getMap(), com.realtime.crossfire.jxclient.map.MapUpdaterState.getMapHeight(), com.realtime.crossfire.jxclient.map.MapUpdaterState.getMapWidth(), com.realtime.crossfire.jxclient.items.ItemSet.getPlayer(), com.realtime.crossfire.jxclient.items.ItemSet.getPlayerInventory(), com.realtime.crossfire.jxclient.stats.Stats.getRange(), com.realtime.crossfire.jxclient.skills.SkillSet.getSkill(), com.realtime.crossfire.jxclient.stats.Stats.getStat(), com.realtime.crossfire.jxclient.items.CfItem.getTag(), com.realtime.crossfire.jxclient.stats.Stats.getTitle(), com.realtime.crossfire.jxclient.items.CfItem.getWeight(), and com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.reportError().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.runScriptCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cmdUnmonitor()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdUnmonitor ( )
private

Processes an "unmonitor" command from the script process.

Definition at line 635 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.server.server.ServerConnection.removeClientSocketListener().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.runScriptCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commandSent()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSent ( @NotNull final String  cmd)

◆ commandSentItem()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSentItem ( @NotNull final String  cmd,
@NotNull final CfItem  item 
)
private

Sends an item info message to the script process.

Parameters
cmdthe message to send
itemthe item to send

Definition at line 316 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSent().

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.cmdRequest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commandSentMap()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSentMap ( @NotNull final CfMap  map,
final int  x,
final int  y 
)
private

◆ compareTo()

int com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.compareTo ( @NotNull final ScriptProcess  o)

Definition at line 742 of file DefaultScriptProcess.java.

◆ equals()

boolean com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.equals ( @Nullable final Object  obj)

◆ getFilename()

String com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.getFilename ( )

Returns the script's filename.

Returns
the script's filename

Implements com.realtime.crossfire.jxclient.scripts.ScriptProcess.

Definition at line 248 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.filename.

◆ getScriptId()

int com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.getScriptId ( )

Returns the script ID identifying this script instance.

Returns
the script ID

Implements com.realtime.crossfire.jxclient.scripts.ScriptProcess.

Definition at line 239 of file DefaultScriptProcess.java.

References com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.scriptId.

◆ hashCode()

int com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.hashCode ( )

◆ killScript()

void com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.killScript ( )

Kills the script process.Does nothing if the process is not running.

Implements com.realtime.crossfire.jxclient.scripts.ScriptProcess.

Definition at line 733 of file DefaultScriptProcess.java.

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandSent().

+ Here is the caller graph for this function:

◆ reportError()

◆ run()

◆ runScriptCommand()

◆ toString()

String com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.toString ( )

Member Data Documentation

◆ clientSocketListener

final ClientSocketListener com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.clientSocketListener
private

The ClientSocketListener attached to crossfireServerConnection to track commands sent to the server.

Definition at line 162 of file DefaultScriptProcess.java.

◆ commandQueue

final CommandQueue com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.commandQueue
private

◆ crossfireServerConnection

final CrossfireServerConnection com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.crossfireServerConnection
private

◆ filename

final String com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.filename
private

◆ floorView

final FloorView com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.floorView
private

◆ in

final InputStream com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.in
private

The InputStream of process.

Definition at line 127 of file DefaultScriptProcess.java.

◆ isMonitoring

boolean com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.isMonitoring
private

Whether a "monitor" command is active.

Definition at line 150 of file DefaultScriptProcess.java.

◆ itemSet

final ItemSet com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.itemSet
private

◆ killed

boolean com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.killed
private

Whether this script has been killed.

Definition at line 155 of file DefaultScriptProcess.java.

◆ mapUpdaterState

final MapUpdaterState com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.mapUpdaterState
private

◆ osw

final OutputStreamWriter com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.osw
private

The OutputStreamWriter associated with process.

Definition at line 133 of file DefaultScriptProcess.java.

◆ packetWatcher

final PacketWatcher com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.packetWatcher
private

The PacketWatcher to process "watch" commands.

Definition at line 145 of file DefaultScriptProcess.java.

◆ process

final Process com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.process
private

The Process instance for the executed child process.

Definition at line 121 of file DefaultScriptProcess.java.

◆ scriptId

◆ scriptProcessListeners

final EventListenerList2<ScriptProcessListener> com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.scriptProcessListeners = new EventListenerList2<>()
private

The ScriptProcessListeners to notify.

Definition at line 139 of file DefaultScriptProcess.java.

◆ skillSet

final SkillSet com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.skillSet
private

The SkillSet for looking up skill names.

Definition at line 115 of file DefaultScriptProcess.java.

Referenced by com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.DefaultScriptProcess().

◆ spellsManager

final Iterable<Spell> com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.spellsManager
private

◆ stats

final Stats com.realtime.crossfire.jxclient.scripts.DefaultScriptProcess.stats
private

The documentation for this class was generated from the following file: