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
Methods
getAllExtensions
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 matchgetExtensionForName
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 extensionsisExtensionLoaded
isGuestObject
loadExtensions
loadExtensions(): void#Attempts extension discovery, initialization, and library registration unless a class loader has already been assigned; in that case, logs a diagnostic and returns. User archives are read from the
Extensions directory. An archive that is itself an entry of another archive — an extension bundled in the mod jar, or a dependency nested in an extension jar — cannot be opened by URLClassLoader where it lies, so ExtensionArchiveCache copies it to a file under Extensions/.cache first. A nested jar entry is named from the source archive and entry metadata; a URL that provides no reliable metadata is named from a digest of its bytes. A cache file is reused when it is still a readable jar and its key still matches the source, and is removed at the end of the load if this load did not use it. Discovery order is fixed: providers the parent class loader can see come first, then the archives named by the bundled manifest in the order it lists them, then the user's archives by file name. Within an archive, providers are visited in the order its service file lists them. An extension that shares its name with an already discovered one is ignored, and the first one found wins — so a user archive cannot replace a bundled extension of the same name. Dependencies are appended to the search path after the initial archives. Each extension is handled on its own. A failure to load an extension's dependencies, initialize it, or register its libraries is reported and skips that extension only; the remaining extensions still load. The same applies to a provider that cannot be instantiated. An extension's dependencies are all materialized and validated before any of them joins the search path, so a later invalid archive cannot publish the earlier ones. Once registration is complete, registered extensions receive the post-load callback. A callback failure is logged without unregistering the extension. A failure that prevents the load from completing does not mark loading complete, so a later query can try again. Extensions registered before the failure are not rolled back, so a retry starts beside that partial state rather than from an empty loader. A query made while an extension is initializing returns the extensions registered so far; it does not start another discovery pass. The current thread's context class loader is set to the extension class loader before extensions initialize, because an extension may load classes of its own while initializing, and is left set on success. A failed load restores the caller's previous context class loader.notLoaded
notLoaded(): boolean#Reports whether extension loading has not yet completed.
Returns:
true until loading completion is recorded, including during a load attempt