Interface IScriptRunModuleConfigurator
- All Known Implementing Classes:
DefaultScriptRunModuleConfigurator
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
JavaNativeModules for a particular IScriptRun.
Each IScriptLoader requires an instance of this class to ensure
proper creation of the environment for a script run.
A script run module configurator is responsible for gathering the exposed classes and expansions from the
ICraftTweakerRegistry and using the information exposed by ScriptRunConfiguration to create the
various ZenCode modules that will then be used to build the ZenCode scripting environment and run scripts.
There are no restrictions on the amount of modules that should be created or on the relationship between them: it is up to the implementation of this class to ensure that the configuration created is valid and will not cause errors at runtime.
This method is a functional interface whose functional method is
populateModules(ICraftTweakerRegistry, ScriptRunConfiguration, ModuleCreator).
- Since:
- 9.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceCreates aJavaNativeModulefrom the given information. -
Method Summary
Modifier and TypeMethodDescriptionstatic IScriptRunModuleConfiguratorcreateDefault(String basePackage) Creates a defaultIScriptRunModuleConfiguratorfor the given base package.populateModules(ICraftTweakerRegistry registry, ScriptRunConfiguration configuration, IScriptRunModuleConfigurator.ModuleCreator creator) Creates all necessary modules for a particular script run.
-
Method Details
-
createDefault
Creates a defaultIScriptRunModuleConfiguratorfor the given base package.The default configurator automatically sets up a hierarchy of modules, with the module for
basePackagesitting at the root of the hierarchy and all expansions being gathered in a special module.To be more precise, the
basePackageis used to gather all classes contained in it and all subpackages and package them into a module with the same name. All the other packages are then scanned and grouped based on their root package. Each root package gives birth to a module that depends uniquely on thebasePackagemodule. At the end, all expansions are then gathered into an"expansions"module, which depends on all previously created modules.As an example, if the
basePackageisfooand there are classes in both thebarandbazroot packages, four modules will be created. Thefoomodule will sit at the root of the hierarchy. Two modules,barandbaz, will then be created and both will depend onfoo. Lastly, a fourth module named"expansions"will be created and it will depend onfoo,bar, andbaz.- Parameters:
basePackage- The base package which will be queried to create the base module.- Returns:
- A script run module configurator carrying out the operations specified above.
- Since:
- 9.1.0
-
populateModules
Collection<JavaNativeModule> populateModules(ICraftTweakerRegistry registry, ScriptRunConfiguration configuration, IScriptRunModuleConfigurator.ModuleCreator creator) throws CompileException Creates all necessary modules for a particular script run.- Parameters:
registry- An instance ofICraftTweakerRegistryfrom which to grab classes and other data for the creation and configuration of the modules.configuration- TheScriptRunConfigurationfor which the script run should be created.creator- AIScriptRunModuleConfigurator.ModuleCreatorwhich is responsible for the actual creation of the modules. Refer toIScriptRunModuleConfigurator.ModuleCreator.createNativeModule(String, String, List, Consumer)for more information.- Returns:
- A
Collectionwith allJavaNativeModules that have been created. The list need not be ordered. - Throws:
CompileException- If the creation of any of the module fails for any reason.- Since:
- 9.1.0
-