Skip to content

Extension ​

com.jsmacrosce.jsmacros.core.extensions.Extension

Provides an extension's identity, dependencies, initialization hook, and optional translations.
Extensions are discovered by the loader as service providers. Scripts can enumerate loaded extensions through context.getCtx().runner.extensions.getAllExtensions():

js
const extensions = context.getCtx().runner.extensions.getAllExtensions().iterator();  
while (extensions.hasNext()) {
 Chat.log(extensions.next().getExtensionName());  
}

Methods ​

getDependencies ​

getDependencies(): Set<URL>#
Reads this extension's dependency descriptor, jsmacrosce.ext.<name>.json. Missing dependency entries are reported to standard error and skipped; descriptor read or parse failures are propagated as runtime exceptions.
Returns: resolved dependency resource URLs; empty when no entries resolve or the descriptor has no dependencies or the literal ${dependencies} placeholder

getDependenciesInternal ​

static getDependenciesInternal(Class<?> clazz, String fname): Set<URL>#
Resolves dependency URLs from a root-classpath JSON descriptor. A primitive dependencies value is split on spaces and each entry is prefixed with META-INF/jsmacrosdeps/; an array supplies root-relative resource paths directly. The exact ${dependencies} primitive is treated as empty. Unresolved resources are reported to standard error and skipped. Descriptor read or parse failures and unsupported dependency formats cause runtime exceptions; other malformed data or value-conversion failures can also cause runtime exceptions.

Parameters:

  • clazz: class used to look up the descriptor and its dependency resources
  • fname: descriptor path relative to the classpath root, without a leading slash
Returns: resolved dependency resource URLs, or an empty set when dependencies are absent or the placeholder is used

getExtensionName ​

getExtensionName(): String#
Returns the extension identifier used by the loader and default resource paths.
Returns: the extension identifier

getTranslations ​

getTranslations(String lang): Map<String, String>#
Reads this extension's translations from its assets/jsmacros/<name>/lang/ resource directory.

Parameters:

  • lang: language-code filename component, such as en_us
Returns: translation values keyed by their JSON object keys; empty if reading or parsing fails or the JSON root is not an object. Values that cannot be converted to strings can cause a runtime exception.

getTranslationsInternal ​

static getTranslationsInternal(Class<?> clazz, String fname): Map<String, String>#
Reads a root-classpath JSON object as a map of string values. Read or parse failures and non-object roots produce an empty map.

Parameters:

  • clazz: class used to look up the resource
  • fname: resource path relative to the classpath root, without a leading slash
Returns: object entries converted to string values, or an empty map on read or parse failure or a non-object root; values that cannot be converted can cause a runtime exception

init ​

init(Core<?, ?> runner): void#
Called by the loader after dependencies are loaded and before this extension's libraries are registered.

Parameters:

  • runner: core instance supplied by the loader

maxCoreVersion ​

maxCoreVersion(): StringSince1.9.0#
Returns the extension's declared maximum JsMacros core version.
Returns: the maximum core version declared by the extension

minCoreVersion ​

minCoreVersion(): StringSince1.9.0#
Returns the extension's declared minimum JsMacros core version.
Returns: the minimum core version declared by the extension