public class DefaultScriptProcess extends java.lang.Object implements java.lang.Runnable, ScriptProcess
ScriptProcess
es.Modifier and Type | Field and Description |
---|---|
private ClientSocketListener |
clientSocketListener
The
ClientSocketListener attached to crossfireServerConnection to track commands sent to the server. |
private CommandQueue |
commandQueue
The
CommandQueue for sending commands. |
private CrossfireServerConnection |
crossfireServerConnection
The connection instance.
|
private java.lang.String |
filename
The script command including arguments.
|
private FloorView |
floorView
The
FloorView to use. |
private java.io.InputStream |
in
The
InputStream of process . |
private boolean |
isMonitoring
Whether a "monitor" command is active.
|
private ItemSet |
itemSet
The
ItemSet instance to use. |
private boolean |
killed
Whether this script has been killed.
|
private MapUpdaterState |
mapUpdaterState
The
MapUpdaterState instance to use. |
private java.io.OutputStreamWriter |
osw
The
OutputStreamWriter associated with process . |
private PacketWatcher |
packetWatcher
The
PacketWatcher to process "watch" commands. |
private java.lang.Process |
process
The
Process instance for the executed child process. |
private int |
scriptId
The script ID identifying this script instance.
|
private EventListenerList2<ScriptProcessListener> |
scriptProcessListeners
The
ScriptProcessListeners to notify. |
private SkillSet |
skillSet
The
SkillSet for looking up skill names. |
private java.lang.Iterable<Spell> |
spellsManager
The
SpellsManager instance to use. |
private Stats |
stats
The
Stats instance to watch. |
Constructor and Description |
---|
DefaultScriptProcess(int scriptId,
java.lang.String filename,
CommandQueue commandQueue,
CrossfireServerConnection crossfireServerConnection,
Stats stats,
FloorView floorView,
ItemSet itemSet,
java.lang.Iterable<Spell> spellsManager,
MapUpdaterState mapUpdaterState,
SkillSet skillSet)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addScriptProcessListener(ScriptProcessListener scriptProcessListener)
Adds a
ScriptProcessListener to be notified. |
private void |
cmdDraw(java.lang.String params)
Processes a "draw" command from the script process.
|
private void |
cmdIssue(java.lang.String params)
Processes a regular "issue" command from the script process.
|
private void |
cmdIssueLock(java.lang.String params)
Processes a "issue lock" command from the script process.
|
private void |
cmdIssueMark(java.lang.String params)
Processes a "issue mark" command from the script process.
|
private void |
cmdMonitor()
Processes a "monitor" command from the script process.
|
private void |
cmdRequest(java.lang.String params)
Processes a "request" command from the script process.
|
private void |
cmdUnmonitor()
Processes an "unmonitor" command from the script process.
|
void |
commandSent(java.lang.String cmd)
Sends a message to the script process.
|
private void |
commandSentItem(java.lang.String cmd,
CfItem item)
Sends an item info message to the script process.
|
private void |
commandSentMap(CfMap map,
int x,
int y)
Sends info about one map cell to the script process.
|
int |
compareTo(ScriptProcess o) |
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getFilename()
Returns the script's filename.
|
int |
getScriptId()
Returns the script ID identifying this script instance.
|
int |
hashCode() |
void |
killScript()
Kills the script process.
|
private void |
reportError(java.lang.String string)
Reports an error while executing client commands.
|
void |
run() |
private void |
runScriptCommand(java.lang.String cmdLine)
Processes a line received from the script process.
|
java.lang.String |
toString() |
@NotNull private final ClientSocketListener clientSocketListener
ClientSocketListener
attached to crossfireServerConnection
to track commands sent to the server.@NotNull private final CommandQueue commandQueue
CommandQueue
for sending commands.@NotNull private final CrossfireServerConnection crossfireServerConnection
@NotNull private final java.lang.String filename
@NotNull private final java.io.InputStream in
InputStream
of process
.private boolean isMonitoring
private boolean killed
@NotNull private final MapUpdaterState mapUpdaterState
MapUpdaterState
instance to use.@NotNull private final java.io.OutputStreamWriter osw
OutputStreamWriter
associated with process
.@NotNull private final PacketWatcher packetWatcher
PacketWatcher
to process "watch" commands.@NotNull private final java.lang.Process process
Process
instance for the executed child process.private final int scriptId
@NotNull private final EventListenerList2<ScriptProcessListener> scriptProcessListeners
ScriptProcessListeners
to notify.@NotNull private final java.lang.Iterable<Spell> spellsManager
SpellsManager
instance to use.public DefaultScriptProcess(int scriptId, @NotNull java.lang.String filename, @NotNull CommandQueue commandQueue, @NotNull CrossfireServerConnection crossfireServerConnection, @NotNull Stats stats, @NotNull FloorView floorView, @NotNull ItemSet itemSet, @NotNull java.lang.Iterable<Spell> spellsManager, @NotNull MapUpdaterState mapUpdaterState, @NotNull SkillSet skillSet) throws java.io.IOException
scriptId
- the script ID identifying the new scriptfilename
- the command including arguments to executecommandQueue
- the command queue for sending commandscrossfireServerConnection
- the server connectionstats
- the stats instance to watchfloorView
- the floor view to useitemSet
- the item set instance to usespellsManager
- the spells manager instance to usemapUpdaterState
- the map updater state instance to useskillSet
- the skill set for looking up skill namesjava.io.IOException
- if the script cannot be createdpublic void addScriptProcessListener(@NotNull ScriptProcessListener scriptProcessListener)
ScriptProcessListener
to be notified.addScriptProcessListener
in interface ScriptProcess
scriptProcessListener
- the listener to addprivate void cmdDraw(@NotNull java.lang.String params)
params
- the command argumentsprivate void cmdIssue(@NotNull java.lang.String params)
params
- the command argumentsprivate void cmdIssueLock(@NotNull java.lang.String params)
params
- the command argumentsprivate void cmdIssueMark(@NotNull java.lang.String params)
params
- the command argumentsprivate void cmdMonitor()
private void cmdRequest(@NotNull java.lang.String params)
params
- the command argumentsprivate void cmdUnmonitor()
public void commandSent(@NotNull java.lang.String cmd)
commandSent
in interface ScriptProcess
cmd
- the message to sendprivate void commandSentItem(@NotNull java.lang.String cmd, @NotNull CfItem item)
cmd
- the message to senditem
- the item to sendprivate void commandSentMap(@NotNull CfMap map, int x, int y)
map
- the map instance to usex
- the cell's x-coordinate relative to the view areay
- the cell's y-coordinate relative to the view areapublic int compareTo(@NotNull ScriptProcess o)
compareTo
in interface java.lang.Comparable<ScriptProcess>
public boolean equals(@Nullable java.lang.Object obj)
equals
in class java.lang.Object
@NotNull public java.lang.String getFilename()
getFilename
in interface ScriptProcess
public int getScriptId()
getScriptId
in interface ScriptProcess
public int hashCode()
hashCode
in class java.lang.Object
public void killScript()
killScript
in interface ScriptProcess
private void reportError(@NotNull java.lang.String string)
string
- the error messagepublic void run()
run
in interface java.lang.Runnable
private void runScriptCommand(@NotNull java.lang.String cmdLine)
cmdLine
- the line@NotNull public java.lang.String toString()
toString
in class java.lang.Object