Interface GravesXModuleController
Implementations are provided by the host (manager/controller). The controller exposed
to a module via ModuleContext.getGravesXModules() can:
- Query enablement state for itself or other modules
- Enable/disable itself (current module)
- Enable/disable another module by key (module.yml name, simple class name, or FQCN)
- Access read-only module descriptors and enumerate all modules
- Query Folia support flags for itself or other modules
- Query module load phase for itself or other modules
Unless otherwise noted, enable/disable operations are idempotent:
invoking them when the target is already in the requested state returns true
(no-op) and does not throw.
Note: the host may choose to permanently mark a module as failed (for example,
if its enable logic throws, or if it is incompatible with the current server
type such as Folia vs non-Folia). In such cases, enableModule(...)
may consistently return false even though no exception is thrown.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDefines the lifecycle phase in which a module is expected to be enabled by the host. -
Method Summary
Modifier and TypeMethodDescriptionvoidDisables this (current) module.booleandisableModule(GravesXModule module) Disables the target module instance.booleandisableModule(Class<? extends GravesXModule> moduleClass) Disables the module with the given implementation class.booleandisableModule(String moduleKey) Disables a target module identified by key.voidEnables this (current) module.booleanenableModule(GravesXModule module) Enables the target module instance.booleanenableModule(Class<? extends GravesXModule> moduleClass) Enables the module with the given implementation class.booleanenableModule(String moduleKey) Enables a target module identified by key.getAuthors(String moduleKey) Convenience accessor forgetModule(moduleKey).getAuthors().Convenience accessor forgetThisModule().getLoadPhase().getLoadPhase(String moduleKey) Convenience accessor forgetModule(moduleKey).getLoadPhase().getModule(GravesXModule module) Looks up a module descriptor by its instance.getModule(Class<? extends GravesXModule> moduleClass) Looks up a module descriptor by its implementation class.Returns the descriptor for a target module identified by key.default StringConvenience accessor forgetModule(moduleKey).getName().Returns the descriptor for this (current) module.default StringgetVersion(String moduleKey) Convenience accessor forgetModule(moduleKey).getVersion().default StringgetWebsite(String moduleKey) Convenience accessor forgetModule(moduleKey).getWebsite().booleanReports whether this (current) module is enabled.booleanisEnabled(GravesXModule module) Returns whether the given module instance is enabled.booleanisEnabled(Class<? extends GravesXModule> moduleClass) Returns whether the module with the given implementation class is enabled.booleanReports whether a target module is enabled.Returns descriptors for all discovered modules, regardless of enablement.voidregisterCommand(String label, GravesXModuleCommand command) Registers a command owned by this module with the GravesX command dispatcher.voidregisterCommand(String label, Class<? extends GravesXModuleCommand> commandClass) Registers a command owned by this module with the GravesX command dispatcher, using a command implementation class.default booleanConvenience accessor forgetThisModule().supportsFolia().default booleansupportsFolia(String moduleKey) Convenience accessor forgetModule(moduleKey).supportsFolia().
-
Method Details
-
isEnabled
boolean isEnabled()Reports whether this (current) module is enabled.- Returns:
trueif the current module is enabled;falseotherwise
-
isEnabled
Reports whether a target module is enabled. ThemoduleKeycan be:- the module.yml
name - the module's simple class name
- the module's fully qualified class name (FQCN)
- Parameters:
moduleKey- identifier for the target module- Returns:
trueif the target module is enabled;falseif disabled or not found
- the module.yml
-
disableModule
void disableModule()Disables this (current) module.Idempotent: if already disabled, no action is taken.
-
disableModule
Disables a target module identified by key.Idempotent: returns
trueif the module becomes or was already disabled.- Parameters:
moduleKey- identifier for the target module (module.yml name, simple class name, or FQCN)- Returns:
trueif state changed or the module was already disabled;falseif not found
-
enableModule
void enableModule()Enables this (current) module.Idempotent: if already enabled, no action is taken.
The host may choose to refuse re-enabling modules that previously failed or are incompatible with the current runtime (e.g. Folia) without throwing; in such cases, this is a no-op.
-
enableModule
Enables a target module identified by key.Idempotent: returns
trueif the module becomes or was already enabled.The host may choose to refuse enabling modules that previously failed or are incompatible with the current runtime (e.g. Folia), in which case this returns
false.- Parameters:
moduleKey- identifier for the target module (module.yml name, simple class name, or FQCN)- Returns:
trueif state changed or the module was already enabled;falseif not found
-
getModule
Returns the descriptor for a target module identified by key.The descriptor provides read-only metadata parsed from
module.yml(name, version, authors, dependencies, flags, etc.) plus runtime state.- Parameters:
moduleKey- identifier for the target module (module.yml name, simple class name, or FQCN)- Returns:
- a descriptor, or
nullif the module is unknown
-
getThisModule
GravesXModuleDescriptor getThisModule()Returns the descriptor for this (current) module.- Returns:
- a non-null descriptor for the current module
-
isEnabled
Returns whether the given module instance is enabled.- Parameters:
module- module instance (e.g.thisor another module)- Returns:
trueif the module is enabled,falseotherwise
-
isEnabled
Returns whether the module with the given implementation class is enabled.- Parameters:
moduleClass- implementation class of the module- Returns:
trueif the module is enabled,falseotherwise
-
disableModule
Disables the target module instance.- Parameters:
module- module instance to disable- Returns:
trueif the module was found and is now disabled (or already disabled);falseif not found
-
disableModule
Disables the module with the given implementation class.- Parameters:
moduleClass- implementation class of the module to disable- Returns:
trueif the module was found and is now disabled (or already disabled);falseif not found
-
enableModule
Enables the target module instance.- Parameters:
module- module instance to enable- Returns:
trueif the module was found and is now enabled (or already enabled);falseif not found
-
enableModule
Enables the module with the given implementation class.- Parameters:
moduleClass- implementation class of the module to enable- Returns:
trueif the module was found and is now enabled (or already enabled);falseif not found
-
getModule
Looks up a module descriptor by its instance.- Parameters:
module- module instance- Returns:
- descriptor for the target module, or
nullif unknown
-
getModule
Looks up a module descriptor by its implementation class.- Parameters:
moduleClass- implementation class of the module- Returns:
- descriptor for the target module, or
nullif unknown
-
listModules
Collection<GravesXModuleDescriptor> listModules()Returns descriptors for all discovered modules, regardless of enablement.- Returns:
- a collection view of all module descriptors (may be empty, never
null)
-
registerCommand
Registers a command owned by this module with the GravesX command dispatcher.The exact wiring to Bukkit's command map is implementation-defined; the intent is that modules can expose lightweight, module-scoped commands without touching the core plugin's
plugin.yml.- Parameters:
label- primary command label (without leading/)command- module command implementation- Throws:
IllegalArgumentException- iflabelis invalid or already in use
-
registerCommand
Registers a command owned by this module with the GravesX command dispatcher, using a command implementation class.The host is responsible for instantiating the command class (for example via a no-arg constructor or dependency injection). This allows any class that implements
GravesXModuleCommandto be registered without the module having to manage the instance lifecycle itself.- Parameters:
label- primary command label (without leading/)commandClass- implementation class of the command- Throws:
IllegalArgumentException- iflabelis invalid or already in use
-
getName
Convenience accessor forgetModule(moduleKey).getName().- Parameters:
moduleKey- identifier for the target module- Returns:
- the module name, or
nullif not found
-
getVersion
Convenience accessor forgetModule(moduleKey).getVersion().- Parameters:
moduleKey- identifier for the target module- Returns:
- the version string, or
nullif not found or unspecified
-
getWebsite
Convenience accessor forgetModule(moduleKey).getWebsite().- Parameters:
moduleKey- identifier for the target module- Returns:
- the website URL, or
nullif not found or unspecified
-
getAuthors
Convenience accessor forgetModule(moduleKey).getAuthors().- Parameters:
moduleKey- identifier for the target module- Returns:
- the authors list,
List.of()if not found or unspecified (nevernull)
-
supportsFolia
Convenience accessor forgetModule(moduleKey).supportsFolia().This reflects the
supportsFoliaboolean parsed from the target module'smodule.yml. If the module cannot be found, this returnsfalse.- Parameters:
moduleKey- identifier for the target module- Returns:
trueif the module exists and declares Folia support;falseotherwise
-
supportsFolia
default boolean supportsFolia()Convenience accessor forgetThisModule().supportsFolia().This reflects the
supportsFoliaboolean parsed from this module'smodule.yml.- Returns:
trueif the current module declares Folia support;falseotherwise
-
getLoadPhase
Convenience accessor forgetModule(moduleKey).getLoadPhase().This reflects the module load phase parsed from
module.yml(or host defaults). If the module cannot be found, this returnsGravesXModuleController.LoadPhase.STARTUP.- Parameters:
moduleKey- identifier for the target module- Returns:
- the target module load phase (never
null)
-
getLoadPhase
Convenience accessor forgetThisModule().getLoadPhase().This reflects this module's load phase parsed from
module.yml(or host defaults). If unset, this returnsGravesXModuleController.LoadPhase.STARTUP.- Returns:
- the current module load phase (never
null)
-