Class AbstractScriptProcess

    • Constructor Detail

      • AbstractScriptProcess

        protected AbstractScriptProcess​(int scriptId,
                                        @NotNull
                                        @NotNull java.lang.String filename,
                                        @NotNull
                                        @NotNull CommandQueue commandQueue,
                                        @NotNull
                                        @NotNull CrossfireServerConnection crossfireServerConnection,
                                        @NotNull
                                        @NotNull Stats stats,
                                        @NotNull
                                        @NotNull FloorView floorView,
                                        @NotNull
                                        @NotNull ItemSet itemSet,
                                        @NotNull
                                        @NotNull java.lang.Iterable<Spell> 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 Detail

      • 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 java.lang.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 java.lang.Runnable
      • readFromScript

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

        @Nullable
        protected abstract @Nullable java.lang.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 java.lang.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 java.lang.String data)
                                       throws java.io.IOException
        Sends some data to the script process.
        Parameters:
        data - the data
        Throws:
        java.io.IOException - if sending fails
      • toString

        @NotNull
        public @NotNull java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareTo

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

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

        public boolean equals​(@Nullable
                              @Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object