Package dev.cwhead.GravesX.module
Class ModuleManager
java.lang.Object
dev.cwhead.GravesX.module.ModuleManager
Manages GravesX modules: discovers, loads, resolves order, and enables/disables them.
Module metadata is parsed from module.yml into ModuleInfo, including
the supportsFolia flag, load phase, and optional libraries list,
which are then exposed via GravesXModuleDescriptor.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classHolds a loaded module instance and its metadata. -
Constructor Summary
ConstructorsConstructorDescriptionModuleManager(Graves plugin) Creates a manager bound to the given plugin and ensures the modules directory exists. -
Method Summary
Modifier and TypeMethodDescriptionScans the modules directory and returns a lightweight list of detected modules by reading onlymodule.ymlfrom each jar (no class loading).voidDisables all modules in reverse topological order.Scan module jars and collect all external Bukkit plugin names that modules declare via pluginDepends and pluginSoftDepends, without loading classes.voidvoidEnables all modules in topological order.Looks up a loaded module by name.voidloadAll()Scans the modules directory, validates jars, loads metadata, constructs instances, imports declared module libraries (if any), and callsGravesXModule.onModuleLoad(ModuleContext).modules()Gets all loaded modules.order()Returns the computed topological load order.pending()Returns the set of modules waiting on missing requirements.voidsetLibraryImporter(LibraryImporter importer) Sets the library importer used by modules to resolve external libraries.booleanTrue if any plugin referenced by any module is present on the server.voidAttempts to enable modules currently pending if their requirements are now met.
-
Constructor Details
-
ModuleManager
Creates a manager bound to the given plugin and ensures the modules directory exists.- Parameters:
plugin- Owning plugin.
-
-
Method Details
-
setLibraryImporter
Sets the library importer used by modules to resolve external libraries.- Parameters:
importer- Library importer to use.
-
modules
Gets all loaded modules.- Returns:
- Unmodifiable view of loaded modules.
-
get
Looks up a loaded module by name.- Parameters:
name- Module name.- Returns:
- Optional containing the module if present.
-
order
Returns the computed topological load order.- Returns:
- List of module names in load order.
-
pending
Returns the set of modules waiting on missing requirements.- Returns:
- Unmodifiable set of pending module names.
-
loadAll
public void loadAll()Scans the modules directory, validates jars, loads metadata, constructs instances, imports declared module libraries (if any), and callsGravesXModule.onModuleLoad(ModuleContext).Also computes the topological order after loading descriptors.
-
enableAll
Enables all modules in topological order. -
enableAll
public void enableAll() -
tryEnablePending
public void tryEnablePending()Attempts to enable modules currently pending if their requirements are now met. -
disableAll
public void disableAll()Disables all modules in reverse topological order. -
detectModules
Scans the modules directory and returns a lightweight list of detected modules by reading onlymodule.ymlfrom each jar (no class loading). -
discoverExternalPluginHints
Scan module jars and collect all external Bukkit plugin names that modules declare via pluginDepends and pluginSoftDepends, without loading classes. -
shouldDeferLoadOnExternalPlugins
public boolean shouldDeferLoadOnExternalPlugins()True if any plugin referenced by any module is present on the server. If true, we defer module load to onEnable so those plugins are fully initialized.
-