From 8d979b31758bdbe7ca3d399e78f2db4dd0bc51a2 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Sun, 3 Feb 2019 14:15:30 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D1=8B=20=D1=81?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=D0=BA=D0=B8=20=D0=B8=20=D0=BF=D0=BE=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D1=81=D0=B8=D0=BB=20=D0=BD=D0=B5=D0=BA=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D1=8B=D0=B5=20=D1=87=D0=B0=D1=81=D1=82=D0=B8=20Upd?= =?UTF-8?q?ater.=20(#164)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FIX] Вынес Timer в LaunchServer и Updater, ведь модули тоже могут его использовать. * [FIX] Updater исправлен парсинг типа версии и номера сборки. --- .../java/ru/gravit/launchserver/LaunchServer.java | 3 ++- .../main/java/ru/gravit/launchserver/Updater.java | 13 +++++-------- build.gradle | 4 ++++ gradle/wrapper/gradle-wrapper.properties | 2 +- .../src/main/java/ru/gravit/utils/Version.java | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 54770fe5..677bf31a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -296,9 +296,9 @@ public static void main(String... args) throws Throwable { // Updates and profiles private volatile List profilesList; - public volatile Map> updatesDirMap; + public final Timer taskPool; public final Updater updater; public static Gson gson; @@ -306,6 +306,7 @@ public static void main(String... args) throws Throwable { public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecException { this.dir = dir; + taskPool = new Timer("Timered task worker thread", true); launcherLibraries = dir.resolve("launcher-libraries"); if (!Files.isDirectory(launcherLibraries)) { Files.deleteIfExists(launcherLibraries); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java b/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java index 7136de39..a6d57254 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java @@ -6,7 +6,6 @@ import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Locale; -import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; @@ -25,12 +24,10 @@ public class Updater extends TimerTask { private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm:ss", Locale.US); private static final long period = 1000*3600; private static final Version VERSION = Launcher.getVersion(); - private final Timer taskPool; private final GHRepository gravitLauncher; private Version parent = VERSION; public Updater(LaunchServer srv) { - this.taskPool = new Timer("Updater thread", true); GHRepository gravitLauncherTmp = null; try { @@ -40,7 +37,7 @@ public Updater(LaunchServer srv) { } this.gravitLauncher = gravitLauncherTmp; run(); - if (srv.config.updatesNotify) taskPool.schedule(this, new Date(System.currentTimeMillis()+period), period); + if (srv.config.updatesNotify) srv.taskPool.schedule(this, new Date(System.currentTimeMillis()+period), period); } @Override @@ -68,8 +65,8 @@ public void run() { LogHelper.error(e); } } - - private static final Pattern startingVerPattern = Pattern.compile("\\d+\\.\\d+\\.\\d+"); + + private static final Pattern startingVerPattern = Pattern.compile("\\d+\\.\\d+\\.\\d+\\.?\\d*"); private static final Pattern pointPatternSpltitter = Pattern.compile("\\."); private static Version parseVer(String relS) { @@ -78,11 +75,11 @@ private static Version parseVer(String relS) { String[] ver = pointPatternSpltitter.split(relS.substring(verMatcher.start(), verMatcher.end())); if (ver.length < 3) return VERSION; return new Version(Integer.parseInt(ver[0]), Integer.parseInt(ver[1]), - Integer.parseInt(ver[2]), ver.length > 3 ? Integer.parseInt(ver[3]) : 0, findRelType(relS.substring(verMatcher.end()+1))); + Integer.parseInt(ver[2]), ver.length > 3 ? Integer.parseInt(ver[3]) : 0, findRelType(relS.substring(verMatcher.end()))); } private static Type findRelType(String substring) { - if (substring.length() < 3 || substring.isEmpty()) return Type.UNKNOWN; + if (substring.isEmpty()) return Type.UNKNOWN; String tS = substring; if (tS.startsWith("-")) tS = tS.substring(1); final String wrk = tS.toLowerCase(Locale.ENGLISH); diff --git a/build.gradle b/build.gradle index d359fea1..feb4e53f 100644 --- a/build.gradle +++ b/build.gradle @@ -28,4 +28,8 @@ } } +wrapper { + distributionType = Wrapper.DistributionType.ALL +} + defaultTasks 'build' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 75b8c7c8..ee671127 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/libLauncher/src/main/java/ru/gravit/utils/Version.java b/libLauncher/src/main/java/ru/gravit/utils/Version.java index 1f0a0577..87d90be8 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/Version.java +++ b/libLauncher/src/main/java/ru/gravit/utils/Version.java @@ -97,7 +97,7 @@ public enum Type { public static final Map unModTypes = Collections.unmodifiableMap(types); static { - Arrays.asList(values()).stream().forEach(type -> types.put(type.name().substring(0, type.name().length() < 3 ? type.name().length() : 3), type)); + Arrays.asList(values()).stream().forEach(type -> types.put(type.name().substring(0, type.name().length() < 3 ? type.name().length() : 3).toLowerCase(Locale.ENGLISH), type)); } } }