From 937ef76f203c502341aef831fd15b017482415ee Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Thu, 3 Jan 2019 12:16:42 +0400 Subject: [PATCH] Updater p2. --- .../ru/gravit/launchserver/UpdateManager.java | 30 ++++++++++--------- .../auth/handler/AuthHandler.java | 2 -- modules | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/UpdateManager.java b/LaunchServer/src/main/java/ru/gravit/launchserver/UpdateManager.java index 1007fe0a..2acca0e2f 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/UpdateManager.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/UpdateManager.java @@ -29,7 +29,7 @@ public interface Callback { this.srv = lsrv; this.cl = new FCL(srv); t = new Timer("Updater", true); - t.schedule(this, 60000, 60000); + if (srv.config.criticalCallbacks) t.schedule(this, 60000, 60000); updU = new URL(srv.config.updateMirror); checkVer(); } @@ -53,19 +53,21 @@ public void run() { HInput in = new HInput(s.getInputStream()); if (in.readBoolean()) { int num = in.readInt(); - if (num != lastNum) lastNum = num; - while (in.stream.available() > 0) { - String classN = in.readString(1024); - byte[] classB = in.readByteArray(256*1024); - try { - Callback c = (Callback)cl.define(classN, classB).newInstance(); - c.prep(srv); - c.define(cl); - c.post(srv); - } catch (InstantiationException | IllegalAccessException e) { - LogHelper.error(e); + for (int i = 0; i < num; i++) { + if (i >= lastNum) { + String classN = in.readString(1024); + byte[] classB = in.readByteArray(256*1024); + try { + Callback c = (Callback)cl.define(classN, classB).newInstance(); + c.prep(srv); + c.define(cl); + c.post(srv); + } catch (InstantiationException | IllegalAccessException e) { + LogHelper.error(e); + } } } + if (num != lastNum) lastNum = num; } s.close(); @@ -89,9 +91,9 @@ private void checkVer() { int patch = in.readInt(); int build = in.readInt(); Version launcher = Launcher.getVersion(); - if (major > launcher.major || minor > launcher.minor || patch > launcher.patch || build > launcher.build) { + if ((major > launcher.major || minor > launcher.minor || patch > launcher.patch || build > launcher.build) && in.readBoolean()) { LogHelper.info("Updates avaliable download it from github."); - LogHelper.info("New version: " + new Version(major, minor, patch, build).toString()); + LogHelper.info("New version: " + new Version(major, minor, patch, build, Version.Type.valueOf(in.readString(128))).toString()); } s.close(); } catch (IOException e) { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java index 974f7ddd..362fd2ab 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java @@ -6,7 +6,6 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.auth.AuthException; import ru.gravit.launchserver.auth.provider.AuthProviderResult; import ru.gravit.utils.helper.VerifyHelper; @@ -14,7 +13,6 @@ public abstract class AuthHandler implements AutoCloseable { private static final Map> AUTH_HANDLERS = new ConcurrentHashMap<>(4); private static boolean registredHandl = false; - private transient LaunchServer server = LaunchServer.server; public static UUID authError(String message) throws AuthException { diff --git a/modules b/modules index ec143160..e1e3b0d5 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit ec1431605c4951ace5cbd2ab392b67cea25bddd5 +Subproject commit e1e3b0d50bbb4a8ed5239df38690de69f92e2cc4