diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index 3c34c5b5..ce374017 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -15,10 +15,7 @@ import pro.gravit.launchserver.launchermodules.LauncherModuleLoader; import pro.gravit.launchserver.manangers.*; import pro.gravit.launchserver.manangers.hook.AuthHookManager; -import pro.gravit.launchserver.modules.events.LaunchServerFullInitEvent; -import pro.gravit.launchserver.modules.events.LaunchServerInitPhase; -import pro.gravit.launchserver.modules.events.LaunchServerPostInitPhase; -import pro.gravit.launchserver.modules.events.NewLaunchServerInstanceEvent; +import pro.gravit.launchserver.modules.events.*; import pro.gravit.launchserver.modules.impl.LaunchServerModulesManager; import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler; import pro.gravit.utils.command.Command; @@ -163,14 +160,23 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La LogHelper.debug("Init components successful"); } // Sync updates dir - if (!IOHelper.isDir(updatesDir)) - Files.createDirectory(updatesDir); - syncUpdatesDir(null); + CommonHelper.newThread("Profiles and updates sync", true, () -> { + try { + if (!IOHelper.isDir(updatesDir)) + Files.createDirectory(updatesDir); + syncUpdatesDir(null); + modulesManager.invokeEvent(new LaunchServerUpdatesSyncEvent(this)); - // Sync profiles dir - if (!IOHelper.isDir(profilesDir)) - Files.createDirectory(profilesDir); - syncProfilesDir(); + // Sync profiles dir + if (!IOHelper.isDir(profilesDir)) + Files.createDirectory(profilesDir); + syncProfilesDir(); + modulesManager.invokeEvent(new LaunchServerProfilesSyncEvent(this)); + } catch (IOException e) { + LogHelper.error(e); + LogHelper.error("Updates/Profiles not synced"); + } + }); launcherModuleLoader.init(); nettyServerSocketHandler = new NettyServerSocketHandler(this); // post init modules diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/events/LaunchServerProfilesSyncEvent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/events/LaunchServerProfilesSyncEvent.java new file mode 100644 index 00000000..c49ff4a5 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/events/LaunchServerProfilesSyncEvent.java @@ -0,0 +1,12 @@ +package pro.gravit.launchserver.modules.events; + +import pro.gravit.launcher.modules.LauncherModule; +import pro.gravit.launchserver.LaunchServer; + +public class LaunchServerProfilesSyncEvent extends LauncherModule.Event { + public final LaunchServer server; + + public LaunchServerProfilesSyncEvent(LaunchServer server) { + this.server = server; + } +} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/modules/events/LaunchServerUpdatesSyncEvent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/events/LaunchServerUpdatesSyncEvent.java new file mode 100644 index 00000000..c8afddf8 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/modules/events/LaunchServerUpdatesSyncEvent.java @@ -0,0 +1,12 @@ +package pro.gravit.launchserver.modules.events; + +import pro.gravit.launcher.modules.LauncherModule; +import pro.gravit.launchserver.LaunchServer; + +public class LaunchServerUpdatesSyncEvent extends LauncherModule.Event { + public final LaunchServer server; + + public LaunchServerUpdatesSyncEvent(LaunchServer server) { + this.server = server; + } +}