Package-level declarations

Types

Link copied to clipboard
class CompileEvalLoad(val libraries: Array<out String>) : LoaderMode

Compiles Koremods Scripts in source form with the supplied libraries.

Link copied to clipboard

Evaluates compiled Koremods Scripts.

Link copied to clipboard
data class Identifier(val namespace: String, val name: String) : Serializable

Uniquely identifies objects within Koremods, such as scripts and transformers. Both namespaces and names must follow a set of rules and are check against their respective patterns - NAMESPACE_PATTERN for namespaces and NAME_PATTERN for names.

Link copied to clipboard
internal class KJvmCompiledScriptLoadedFromJar(scriptClassFQName: String, path: Path) : CompiledScript

Represents a CompiledScript loaded from a Path. The script will prefer the ClassLoader created by the active KoremodsLaunchPlugin if available.

Link copied to clipboard

Handles locating, parsing, evaluating and optionally compiling Koremods Scripts and Koremods Script Packs.

Link copied to clipboard
data class KoremodsPackConfig(val namespace: String, val scripts: List<String>)

Dedicated Koremods script pack config

Link copied to clipboard
data class KoremodsScript(val identifier: Identifier, val handler: TransformerHandler)

A loaded and initialized Koremods Script.

Link copied to clipboard
data class KoremodsScriptPack(val namespace: String, val path: Path, val scripts: List<KoremodsScript>)

A loaded and initialized Koremods Script Pack.

Link copied to clipboard
sealed class LoaderMode(val extension: String)

Defines behavior for how Koremods should proceed when loading Script Packs.

Link copied to clipboard
internal class MemoryClassLoader(resources: Map<String, ByteArray>, parent: ClassLoader?) : ClassLoader

Loads classes from bytes stored in program memory. Used by KJvmCompiledScriptLoadedFromJar to load compiled script classes.

Link copied to clipboard
class PathScriptSource(path: Path) : ExternalSourceCode, Serializable

A Script Source that points to a java NIO Path.

Link copied to clipboard
data class RawScript<T>(val identifier: Identifier, val source: T)

Represents a Koremods Script in raw, unfinalized form with a source attached.

Link copied to clipboard
data class RawScriptPack<T>(val namespace: String, val path: Path, val scripts: List<RawScript<T>>)

Represents a Koremods Script Pack in raw, unfinalized form with script sources.

Link copied to clipboard

An exception thrown when an error is encountered during the script evaluation process.

Properties

Link copied to clipboard
const val CONFIG_FILE: String

File name used by both global and script pack config files

Link copied to clipboard

Path to a script pack's configuration file relative to its root

Link copied to clipboard
const val LOGGER_GROUP: String

Logger name prefix used by Koremods logger instances

Link copied to clipboard
const val NAMESPACE: String

Koremods self identifier.

Functions

Link copied to clipboard
fun <T : Transformer<U>, U> applyTransform(identifier: Any, transformers: List<T>, node: U): Collection<TransformerPropertiesStore>

Transform an ASM node using Koremods Transformers

Link copied to clipboard
fun compileScript(identifier: Identifier, source: SourceCode, configBuilder: ScriptCompilationConfiguration.Builder.() -> Unit): ResultWithDiagnostics<CompiledScript>

Invoke the kotlin script compiler.

Link copied to clipboard
internal fun compileScriptPacks(packs: Collection<RawScriptPack<SourceCode>>, libraries: Array<out String> = emptyArray()): List<RawScriptPack<CompiledScript>>

Process and compile scripts from each script pack, returning a new list of packs with the compiled results.

Link copied to clipboard
fun compileScriptResult(identifier: Identifier, source: SourceCode, configBuilder: ScriptCompilationConfiguration.Builder.() -> Unit): CompiledScript

Compile a source script and ensure the process was successful.

Link copied to clipboard
fun RawScript<SourceCode>.compileScriptResult(libraries: Array<out String>): CompiledScript

Compile a Source script with additional configuration and return the compilation result.

Link copied to clipboard
fun createLogger(name: String): Logger
Link copied to clipboard
fun evalScript(identifier: Identifier, script: CompiledScript, logger: Logger): ResultWithDiagnostics<EvaluationResult>

Evaluate a compiled script by loading its classes and return the evaluation result.

Link copied to clipboard
internal fun evalScriptPacks(compiledPacks: Collection<RawScriptPack<CompiledScript>>): List<KoremodsScriptPack>

Evaluate a set of raw, compiled koremods scripts by loading their classes into the JVM and retrieving their list of transformers.

Link copied to clipboard
fun evalTransformers(identifier: Identifier, script: CompiledScript, logger: Logger): TransformerHandler

Evaluate a compiled script by loading its classes and retrieving its defined transformers.

Link copied to clipboard
fun Path.loadScriptFromJar(): CompiledScript

Load a compiled script from a Path that points to a valid jar file.

Link copied to clipboard
internal fun locateScripts(namespace: String, scripts: List<String>, rootPath: Path, scriptExt: String): List<RawScript<Path>>

Locate defined scripts within a script pack at the given path

Link copied to clipboard
fun Logger.logResultErrors(result: ResultWithDiagnostics.Failure)

Dump errors from a ResultWithDiagnostics to a Log4J Logger.

Link copied to clipboard
fun <T> Logger.measureMillis(level: Level, message: String, block: () -> T): T

Measure and log code execution time in milliseconds.

Link copied to clipboard
inline fun <T> parseConfig(reader: Reader): T

Parses a config object from a raw data stream.

Link copied to clipboard
internal fun readCompiledScripts(packs: Collection<RawScriptPack<Path>>): List<RawScriptPack<CompiledScript>>

Read the bytecode contents of compiled scripts from script packs.

Link copied to clipboard

Read the byte contents of all entries in a JarInputStream.

Link copied to clipboard
internal fun readScriptPack(parent: Path, configPath: Path, rootPath: Path, extension: String): RawScriptPack<Path>?

Read the contents of a Koremods Script Pack at the specified path

Link copied to clipboard
fun readScriptSource(identifier: Identifier, path: Path): SourceCode

Read the contents of a script from a Path and return its SourceCode.

Link copied to clipboard

Read the Source Code contents of pack scripts.

Link copied to clipboard
fun scanPath(path: Path, scriptExtension: String = KOREMODS_SCRIPT_EXTENSION): RawScriptPack<Path>?

Search for a Koremods Script Pack in the specified path

Link copied to clipboard
fun scanPaths(paths: Iterable<Path>, scriptExtension: String): List<RawScriptPack<Path>>

Search for Koremods Script Packs in the specified paths