com.realtime.crossfire.jxclient.scripts
Class ScriptManager

java.lang.Object
  extended by com.realtime.crossfire.jxclient.scripts.ScriptManager

public class ScriptManager
extends java.lang.Object

Maintains currently running script processes.


Field Summary
private  CommandQueue commandQueue
          The CommandQueue for sending commands.
private  CrossfireServerConnection crossfireServerConnection
          The CrossfireServerConnection instance.
private  FloorView floorView
          The FloorView to use.
private  ItemSet itemSet
          The ItemSet instance to use.
private  CfMapUpdater mapUpdater
          The CfMapUpdater instance to use.
private  int nextScriptId
          The script ID for the next created script.
private  java.util.Collection<ScriptProcess> scriptProcesses
          All running ScriptProcesses.
private  SkillSet skillSet
          The SkillSet for looking up skill names.
private  java.lang.Iterable<Spell> spellsManager
          The spells manager instance to use.
private  Stats stats
          The Stats instance to watch.
 
Constructor Summary
ScriptManager(CommandQueue commandQueue, CrossfireServerConnection crossfireServerConnection, Stats stats, FloorView floorView, ItemSet itemSet, java.lang.Iterable<Spell> spellsManager, CfMapUpdater mapUpdater, SkillSet skillSet)
          Creates a new instance.
 
Method Summary
private  java.util.Set<ScriptProcess> getScriptByScriptId(int scriptId)
          Returns all running scripts matching a given script ID.
 java.util.Set<ScriptProcess> getScripts(java.lang.String partialScriptName)
          Returns all running scripts matching a given (partial) name or a script ID.
private  java.util.Set<ScriptProcess> getScriptsByName(java.lang.CharSequence partialScriptName)
          Returns all running scripts matching a given (partial) name.
 boolean hasScripts()
          Returns whether at least one script is running.
 void newScript(java.lang.String command)
          Creates a new script instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandQueue

@NotNull
private final CommandQueue commandQueue
The CommandQueue for sending commands.


crossfireServerConnection

@NotNull
private final CrossfireServerConnection crossfireServerConnection
The CrossfireServerConnection instance.


floorView

@NotNull
private final FloorView floorView
The FloorView to use.


itemSet

@NotNull
private final ItemSet itemSet
The ItemSet instance to use.


mapUpdater

@NotNull
private final CfMapUpdater mapUpdater
The CfMapUpdater instance to use.


nextScriptId

private int nextScriptId
The script ID for the next created script.


scriptProcesses

@NotNull
private final java.util.Collection<ScriptProcess> scriptProcesses
All running ScriptProcesses.


skillSet

@NotNull
private final SkillSet skillSet
The SkillSet for looking up skill names.


spellsManager

@NotNull
private final java.lang.Iterable<Spell> spellsManager
The spells manager instance to use.


stats

@NotNull
private final Stats stats
The Stats instance to watch.

Constructor Detail

ScriptManager

public ScriptManager(@NotNull
                     CommandQueue commandQueue,
                     @NotNull
                     CrossfireServerConnection crossfireServerConnection,
                     @NotNull
                     Stats stats,
                     @NotNull
                     FloorView floorView,
                     @NotNull
                     ItemSet itemSet,
                     @NotNull
                     java.lang.Iterable<Spell> spellsManager,
                     @NotNull
                     CfMapUpdater mapUpdater,
                     @NotNull
                     SkillSet skillSet)
Creates a new instance.

Parameters:
commandQueue - the command queue for sending commands
crossfireServerConnection - the connection instance
stats - the stats instance to watch
floorView - the floor view to use
itemSet - the item set instance to use
spellsManager - the spells manager instance to use
mapUpdater - the map updater instance to use
skillSet - the skill set for looking up skill names
Method Detail

getScriptByScriptId

@NotNull
private java.util.Set<ScriptProcess> getScriptByScriptId(int scriptId)
Returns all running scripts matching a given script ID.

Parameters:
scriptId - the script ID
Returns:
the matching scripts, possibly empty

getScripts

@NotNull
public java.util.Set<ScriptProcess> getScripts(@NotNull
                                                       java.lang.String partialScriptName)
Returns all running scripts matching a given (partial) name or a script ID.

Parameters:
partialScriptName - the partial name or a script ID to match against; an empty string matches all scripts
Returns:
the matching scripts, possibly empty

getScriptsByName

@NotNull
private java.util.Set<ScriptProcess> getScriptsByName(@NotNull
                                                              java.lang.CharSequence partialScriptName)
Returns all running scripts matching a given (partial) name.

Parameters:
partialScriptName - the partial script name; an empty string matches all scripts
Returns:
the matching scripts, possibly empty

hasScripts

public boolean hasScripts()
Returns whether at least one script is running.

Returns:
whether at least one script is running

newScript

public void newScript(@NotNull
                      java.lang.String command)
Creates a new script instance.

Parameters:
command - the script command including arguments