From 497e07094a25b4ef4e6d8c4f177e7541beebe843 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 26 Aug 2019 17:37:14 +0700 Subject: [PATCH] =?UTF-8?q?[FIX][EXPERIMENTAL]=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=D0=BE?= =?UTF-8?q?=D0=B4=D0=BD=D0=BE=D0=B7=D0=BD=D0=B0=D1=87=D0=BD=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B8=20InitPhase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/impl/LaunchServerCoreModule.java | 8 ++++---- .../gravit/launcher/modules/LauncherModule.java | 12 ++++++------ .../launcher/modules/impl/SimpleModuleManager.java | 14 +++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerCoreModule.java b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerCoreModule.java index 2a1da839..c816d073 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerCoreModule.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/impl/LaunchServerCoreModule.java @@ -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"); } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java index 9ed1b65d..3f197446 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/LauncherModule.java @@ -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; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java index b6694be4..d80d3884 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/modules/impl/SimpleModuleManager.java @@ -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; }