Skip to content

ExtensionLoader ​

com.jsmacrosce.jsmacros.core.extensions.ExtensionLoader

Discovers and initializes extensions associated with a core; queries other than notLoaded() trigger loading when completion has not been recorded. Returned extension sets are independent live backing sets; mutating one does not reconcile the others or registered libraries.

js
const Client = Java.type("com.jsmacrosce.jsmacros.client.JsMacrosClient");  
Chat.log(Client.clientCore.extensions.getAllLanguageExtensions().size());

Constructors ​

new ExtensionLoader ​

new ExtensionLoader(Core<?, ?> core)#
Stores the core and resolves its configured Extensions directory without loading extensions or creating that directory.

Parameters:

  • core: associated core with initialized configuration

Methods ​

getAllExtensions ​

getAllExtensions(): Set<Extension>#
Loads extensions if needed and returns the live mutable backing set of all registered extensions.
Returns: the backing set of registered extensions

getAllLanguageExtensions ​

getAllLanguageExtensions(): Set<LanguageExtension>#
Loads extensions if needed and returns the live mutable backing set of language extensions.
Returns: the backing set of language extensions

getAllLibraryExtensions ​

getAllLibraryExtensions(): Set<LibraryExtension>#
Loads extensions if needed and returns the live mutable backing set of library extensions.
Returns: the backing set of library extensions

getExtensionForFile ​

getExtensionForFile(File file): LanguageExtension#
Loads extensions if needed and selects a language extension matching the file; when multiple matches include MATCH_WITH_NAME, only those named matches are considered. Candidates are sorted by negated int priority, normally preferring higher priorities; Integer.MIN_VALUE overflows and sorts first. Equal priorities have no guaranteed selection.

Parameters:

  • file: candidate file passed to language extensions for matching
Returns: the selected matching extension, or null if none match

getExtensionForName ​

getExtensionForName(String extName): Extension#
Loads extensions if needed and returns the first registered extension with an exact name match; duplicate names have no guaranteed selection order.

Parameters:

  • extName: exact registered extension name
Returns: a matching extension, or null if none matches

getHighestPriorityExtension ​

getHighestPriorityExtension(): LanguageExtension#
Loads extensions if needed, then selects the language extension with the greatest priority while the cache is empty. Equal priorities have no guaranteed selection; a non-null cache is not invalidated by changes to the live language-extension set.
Returns: the cached or selected extension, or null if there are no language extensions

isExtensionLoaded ​

isExtensionLoaded(String name): boolean#
Loads extensions if needed, then checks for an exact extension-name match in the registered set.

Parameters:

  • name: exact extension name
Returns: whether a registered extension has that name

isGuestObject ​

isGuestObject(Object obj): boolean#
Loads extensions if needed and asks the loaded language extensions whether they recognize the object.

Parameters:

  • obj: object to inspect
Returns: true if any loaded language extension recognizes it; false otherwise

loadExtensions ​

loadExtensions(): void#
Attempts extension discovery, initialization, and library registration unless a class loader has already been assigned; in that case, prints a diagnostic and returns. Creates the Extensions directory if needed, uses its regular files as the initial class-loader search path, discovers extension providers, and extracts bundled extensions and provider dependencies into Extensions/tmp. Completion is recorded only after provider initialization and registration finish. A failure after class-loader assignment can leave partial state and prevents another attempt; earlier failures do not set that sentinel. After dependency loading, the current thread's context class loader is changed and not restored, even if later initialization fails. Caught I/O, dependency, and initialization exceptions are wrapped in RuntimeException.

notLoaded ​

notLoaded(): boolean#
Reports whether extension loading has not yet completed.
Returns: true until loading completion is recorded, including during a load attempt