mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[DOC] Документация по новой системе модулей
This commit is contained in:
parent
a6e4359216
commit
0920fe18f4
2 changed files with 56 additions and 0 deletions
|
@ -24,6 +24,13 @@ public LauncherModuleInfo getModuleInfo() {
|
||||||
return moduleInfo;
|
return moduleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module initialization status at the current time
|
||||||
|
* CREATED - Module status immediately after loading
|
||||||
|
* INIT - The state of the module during the execution of the method init()
|
||||||
|
* FINISH - Status of the module after initialization
|
||||||
|
*/
|
||||||
public enum InitStatus
|
public enum InitStatus
|
||||||
{
|
{
|
||||||
CREATED,
|
CREATED,
|
||||||
|
@ -58,6 +65,11 @@ public LauncherModule setInitStatus(InitStatus initStatus) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The internal method used by the ModuleManager
|
||||||
|
* DO NOT TOUCH
|
||||||
|
* @param context Private context
|
||||||
|
*/
|
||||||
public void setContext(LauncherModulesContext context)
|
public void setContext(LauncherModulesContext context)
|
||||||
{
|
{
|
||||||
if(this.context != null) throw new IllegalStateException("Module already set context");
|
if(this.context != null) throw new IllegalStateException("Module already set context");
|
||||||
|
@ -66,19 +78,56 @@ public void setContext(LauncherModulesContext context)
|
||||||
this.modulesConfigManager = context.getModulesConfigManager();
|
this.modulesConfigManager = context.getModulesConfigManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called before initializing all modules and resolving dependencies.
|
||||||
|
* <b>You can</b>:
|
||||||
|
* Use to Module Manager
|
||||||
|
* Add custom modules not described in the manifest
|
||||||
|
* Change information about your module or modules you control
|
||||||
|
* <b>You can not</b>:
|
||||||
|
* Use your dependencies
|
||||||
|
* Use API Launcher, LaunchServer, ServerWrapper
|
||||||
|
* Change the names of any modules
|
||||||
|
*/
|
||||||
public void preInit() {
|
public void preInit() {
|
||||||
//NOP
|
//NOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Basic module initialization method
|
||||||
|
* <b>You can</b>:
|
||||||
|
* Subscribe to events
|
||||||
|
* Use your dependencies
|
||||||
|
* Use provided initContext
|
||||||
|
* Receive modules and access the module’s internal methods
|
||||||
|
* <b>You can not</b>:
|
||||||
|
* Modify module description, dependencies
|
||||||
|
* Add modules
|
||||||
|
* Read configuration
|
||||||
|
* @param initContext <tr>null</tr> on module initialization during boot or startup
|
||||||
|
* Not <tr>null</tr> during module initialization while running
|
||||||
|
*/
|
||||||
public abstract void init(LauncherInitContext initContext);
|
public abstract void init(LauncherInitContext initContext);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an event handler for the current module
|
||||||
|
* @param handle your event handler
|
||||||
|
* @param tClass event class
|
||||||
|
* @param <T> event type
|
||||||
|
* @return true if adding a handler was successful
|
||||||
|
*/
|
||||||
protected <T extends Event> boolean registerEvent(EventHandler<T> handle, Class<T> tClass)
|
protected <T extends Event> boolean registerEvent(EventHandler<T> handle, Class<T> tClass)
|
||||||
{
|
{
|
||||||
eventMap.put(tClass, handle);
|
eventMap.put(tClass, handle);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call the handler of the current module
|
||||||
|
* @param event event handled
|
||||||
|
* @param <T> event type
|
||||||
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public final <T extends Event> void callEvent(T event)
|
public final <T extends Event> void callEvent(T event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,5 +23,12 @@ default <T extends LauncherModule> boolean containsModule(Class<? extends T> cl
|
||||||
ClassLoader getModuleClassLoader();
|
ClassLoader getModuleClassLoader();
|
||||||
<T extends LauncherModule> T getModule(Class<? extends T> clazz);
|
<T extends LauncherModule> T getModule(Class<? extends T> clazz);
|
||||||
<T extends LauncherModule> T findModule(Class<? extends T> clazz, Predicate<Version> versionPredicate);
|
<T extends LauncherModule> T findModule(Class<? extends T> clazz, Predicate<Version> versionPredicate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoke event processing for all modules.
|
||||||
|
* Event processing is carried out in the order of the modules in the list (sorted by priority)
|
||||||
|
* @param event event handled
|
||||||
|
* @param <T> event type
|
||||||
|
*/
|
||||||
<T extends LauncherModule.Event> void invokeEvent(T event);
|
<T extends LauncherModule.Event> void invokeEvent(T event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue