Interface IScriptRunManager

All Known Implementing Classes:
ScriptRunManager

public interface IScriptRunManager
Manages the creation and lifecycle of IScriptRuns, while also dealing with IActions.
Since:
9.1.0
  • Method Details

    • createScriptRun

      IScriptRun createScriptRun(ScriptRunConfiguration configuration)
      Creates an IScriptRun with the specified ScriptRunConfiguration.

      The script run will execute all scripts that are present in the default scripts directory. In this instance, a valid script file is identified by a Path whose BasicFileAttributes report a regular file and whose file name ends with .zs.

      During the discovery phase, any file with a suspicious name will raise a warning in the logs.

      Parameters:
      configuration - The configuration of the script run.
      Returns:
      A script run that carries out the specified operations.
      Since:
      9.1.0
    • createScriptRun

      IScriptRun createScriptRun(Path root, ScriptRunConfiguration configuration)
      Creates an IScriptRun with the specified ScriptRunConfiguration executing all valid scripts from the given root.

      In this instance, a valid script file is identified by a Path whose BasicFileAttributes report a regular file and whose file name ends with .zs.

      During the discovery phase, any file with a suspicious name will raise a warning in the logs.

      Parameters:
      root - The root Path from which CraftTweaker should look for scripts.
      configuration - The configuration of the script run.
      Returns:
      A script run that carries out the specified operations.
      Since:
      9.1.0
    • createScriptRun

      IScriptRun createScriptRun(Path root, ScriptDiscoveryConfiguration discoveryConfiguration, ScriptRunConfiguration runConfiguration)
      Creates an IScriptRun with the specified ScriptRunConfiguration executing all valid scripts discovered according to the given ScriptDiscoveryConfiguration from the given root.

      In this instance, a valid script file is identified by a Path whose BasicFileAttributes report a regular file and whose file name ends with .zs.

      Parameters:
      root - The root Path from which CraftTweaker should look for scripts.
      discoveryConfiguration - The configuration for the discovery process.
      runConfiguration - The configuration of the script run.
      Returns:
      A script run that carries out the specified operations.
      Since:
      10.1.0
    • createScriptRun

      IScriptRun createScriptRun(Path root, List<Path> files, ScriptRunConfiguration configuration)
      Creates an IScriptRun with the specified ScriptRunConfiguration executing the script files in the files list.

      In this instance, all Paths given in files are assumed to be valid files. The path given as root, on the other hand, is used to properly identify the name of the script file for the ZenCode scripting environment. For this reason, it is mandatory for root to be a valid parent of all files listed in the files list.

      Parameters:
      root - The root which contains all files listed in files.
      files - The files that CraftTweaker should execute in the script run.
      configuration - The configuration of the script run.
      Returns:
      A script run that carries out the specified operations.
      Since:
      9.1.0
    • createScriptRun

      IScriptRun createScriptRun(List<SourceFile> sources, ScriptRunConfiguration configuration)
      Creates an IScriptRun with the specified ScriptRunConfiguration executing the given ZenCode SourceFiles.

      No restrictions are imposed on the type of the source files given.

      Parameters:
      sources - The source files to execute in the script run.
      configuration - The configuration of the script run.
      Returns:
      A script run that carries out the specified operations.
      Since:
      9.1.0
    • currentRunInfo

      IScriptRunInfo currentRunInfo()
      Obtains the IScriptRunInfo of the currently executing IScriptRun, if any.

      If no script run is currently executing, a NullPointerException is thrown instead. It is the caller's responsibility to verify that this method can only ever be called during a script run execution.

      A script run is considered executing only when its IScriptRun.execute() method is operating.

      To get information for a specific script run, consider using IScriptRun.specificRunInfo() instead.

      Returns:
      The information for the currently executing script run, if any.
      Since:
      9.1.0
    • applyAction

      void applyAction(IAction action)
      Applies the given action.

      Application of the action requires an IScriptRun to be currently executing. Attempting to apply an action outside of a script run will result in an IllegalStateException being thrown.

      Parameters:
      action - The action to apply.
      Since:
      9.1.0