mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX][EXPERIMENTAL] Исправление неоднозначности InitPhase
This commit is contained in:
parent
a980935092
commit
497e07094a
3 changed files with 17 additions and 17 deletions
|
@ -3,7 +3,7 @@
|
|||
import pro.gravit.launcher.modules.LauncherInitContext;
|
||||
import pro.gravit.launcher.modules.LauncherModule;
|
||||
import pro.gravit.launcher.modules.LauncherModuleInfo;
|
||||
import pro.gravit.launchserver.modules.events.LaunchServerInitPhase;
|
||||
import pro.gravit.launcher.modules.events.InitPhase;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
|
@ -14,11 +14,11 @@ public LaunchServerCoreModule() {
|
|||
|
||||
@Override
|
||||
public void init(LauncherInitContext initContext) {
|
||||
registerEvent(this::testEvent, LaunchServerInitPhase.class);
|
||||
registerEvent(this::testEvent, InitPhase.class);
|
||||
}
|
||||
|
||||
public void testEvent(LaunchServerInitPhase event)
|
||||
public void testEvent(InitPhase event)
|
||||
{
|
||||
LogHelper.debug("[LaunchServerCore] Event LaunchServerInitPhase passed");
|
||||
//LogHelper.debug("[LaunchServerCore] Event LaunchServerInitPhase passed");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public abstract class LauncherModule {
|
|||
protected LauncherModulesManager modulesManager;
|
||||
protected final LauncherModuleInfo moduleInfo;
|
||||
protected ModulesConfigManager modulesConfigManager;
|
||||
protected InitPhase initPhase = InitPhase.CREATED;
|
||||
protected InitStatus initStatus = InitStatus.CREATED;
|
||||
|
||||
protected LauncherModule() {
|
||||
moduleInfo = new LauncherModuleInfo("UnknownModule");
|
||||
|
@ -24,7 +24,7 @@ public LauncherModuleInfo getModuleInfo() {
|
|||
return moduleInfo;
|
||||
}
|
||||
|
||||
public enum InitPhase
|
||||
public enum InitStatus
|
||||
{
|
||||
CREATED,
|
||||
INIT,
|
||||
|
@ -49,12 +49,12 @@ public Event cancel() {
|
|||
protected boolean cancel = false;
|
||||
}
|
||||
|
||||
public InitPhase getInitPhase() {
|
||||
return initPhase;
|
||||
public InitStatus getInitStatus() {
|
||||
return initStatus;
|
||||
}
|
||||
|
||||
public LauncherModule setInitPhase(InitPhase initPhase) {
|
||||
this.initPhase = initPhase;
|
||||
public LauncherModule setInitStatus(InitStatus initStatus) {
|
||||
this.initStatus = initStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,13 +67,13 @@ public void initModules(LauncherInitContext initContext) {
|
|||
isAnyModuleLoad = false;
|
||||
for(LauncherModule module : modules)
|
||||
{
|
||||
if(!module.getInitPhase().equals(LauncherModule.InitPhase.CREATED)) continue;
|
||||
if(!module.getInitStatus().equals(LauncherModule.InitStatus.CREATED)) continue;
|
||||
if(checkDepend(module))
|
||||
{
|
||||
isAnyModuleLoad = true;
|
||||
module.setInitPhase(LauncherModule.InitPhase.INIT);
|
||||
module.setInitStatus(LauncherModule.InitStatus.INIT);
|
||||
module.init(initContext);
|
||||
module.setInitPhase(LauncherModule.InitPhase.FINISH);
|
||||
module.setInitStatus(LauncherModule.InitStatus.FINISH);
|
||||
loaded++;
|
||||
}
|
||||
}
|
||||
|
@ -81,13 +81,13 @@ public void initModules(LauncherInitContext initContext) {
|
|||
}
|
||||
for(LauncherModule module : modules)
|
||||
{
|
||||
if(module.getInitPhase().equals(LauncherModule.InitPhase.CREATED))
|
||||
if(module.getInitStatus().equals(LauncherModule.InitStatus.CREATED))
|
||||
{
|
||||
LauncherModuleInfo info = module.getModuleInfo();
|
||||
LogHelper.warning("Module %s required %s. Cyclic dependencies?", info.name, Arrays.toString(info.dependencies));
|
||||
module.setInitPhase(LauncherModule.InitPhase.INIT);
|
||||
module.setInitStatus(LauncherModule.InitStatus.INIT);
|
||||
module.init(initContext);
|
||||
module.setInitPhase(LauncherModule.InitPhase.FINISH);
|
||||
module.setInitStatus(LauncherModule.InitStatus.FINISH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ private boolean checkDepend(LauncherModule module)
|
|||
{
|
||||
LauncherModule depModule = getModule(dep);
|
||||
if(depModule == null) throw new RuntimeException(String.format("Module %s required %s. %s not found", info.name, dep, dep));
|
||||
if(depModule.getInitPhase().equals(LauncherModule.InitPhase.CREATED)) return false;
|
||||
if(depModule.getInitStatus().equals(LauncherModule.InitStatus.CREATED)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue