Class AbstractScriptProcess

java.lang.Object
com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess
All Implemented Interfaces:
ScriptProcess, Comparable<ScriptProcess>, Runnable
Direct Known Subclasses:
DefaultScriptProcess

public abstract class AbstractScriptProcess extends Object implements Runnable, ScriptProcess
Default implementation for ScriptProcesses.
  • Constructor Details

    • AbstractScriptProcess

      protected AbstractScriptProcess(int scriptId, @NotNull @NotNull String filename, @NotNull @NotNull CommandQueue commandQueue, @NotNull @NotNull CrossfireServerConnection crossfireServerConnection, @NotNull @NotNull Stats stats, @NotNull @NotNull FloorView floorView, @NotNull @NotNull ItemSet itemSet, @NotNull @NotNull SpellsManager spellsManager, @NotNull @NotNull MapUpdaterState mapUpdaterState, @NotNull @NotNull SkillSet skillSet)
      Creates a new instance.
      Parameters:
      scriptId - the script ID identifying the new script
      filename - the command including arguments to execute
      commandQueue - the command queue for sending commands
      crossfireServerConnection - the server connection
      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
      mapUpdaterState - the map updater state instance to use
      skillSet - the skill set for looking up skill names
  • Method Details

    • getScriptId

      public int getScriptId()
      Description copied from interface: ScriptProcess
      Returns the script ID identifying this script instance.
      Specified by:
      getScriptId in interface ScriptProcess
      Returns:
      the script ID
    • getFilename

      @NotNull public @NotNull String getFilename()
      Description copied from interface: ScriptProcess
      Returns the script's filename.
      Specified by:
      getFilename in interface ScriptProcess
      Returns:
      the script's filename
    • run

      public void run()
      Specified by:
      run in interface Runnable
    • readFromScript

      @Nullable protected abstract @Nullable String readFromScript() throws IOException
      Reads a line from the script process.
      Returns:
      the line or null if the script has exited
      Throws:
      IOException - if reading failed
    • waitForTermination

      @Nullable protected abstract @Nullable String waitForTermination()
      Waits until the script has terminated.
      Returns:
      the termination reason or null if the script exited normally
    • commandSent

      public void commandSent(@NotNull @NotNull String cmd)
      Description copied from interface: ScriptProcess
      Sends a message to the script process.
      Specified by:
      commandSent in interface ScriptProcess
      Parameters:
      cmd - the message to send
    • writeToScript

      protected abstract void writeToScript(@NotNull @NotNull String data) throws IOException
      Sends some data to the script process.
      Parameters:
      data - the data
      Throws:
      IOException - if sending fails
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object
    • addScriptProcessListener

      public void addScriptProcessListener(@NotNull @NotNull ScriptProcessListener scriptProcessListener)
      Description copied from interface: ScriptProcess
      Adds a ScriptProcessListener to be notified.
      Specified by:
      addScriptProcessListener in interface ScriptProcess
      Parameters:
      scriptProcessListener - the listener to add
    • compareTo

      public int compareTo(@NotNull @NotNull ScriptProcess o)
      Specified by:
      compareTo in interface Comparable<ScriptProcess>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable @Nullable Object obj)
      Overrides:
      equals in class Object