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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Holds 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 TypeMethodDescriptionvoid
Disables 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.void
Enables all modules in topological order.Looks up a loaded module by name.void
loadAll()
Scans the modules directory, validates jars, loads metadata, constructs instances, and calls onModuleLoad.modules()
Gets all loaded modules.order()
Returns the computed topological load order.pending()
Returns the set of modules waiting on missing requirements.void
setLibraryImporter
(LibraryImporter importer) Sets the library importer used by modules to resolve external libraries.boolean
True if any plugin referenced by any module is present on the server.void
Attempts 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, and calls onModuleLoad. Also computes the topological order after loading descriptors. -
enableAll
public void enableAll()Enables all modules in topological order. -
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. -
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.
-