diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java b/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java index 4928a9f4..7e7d0ee6 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/Updater.java @@ -23,6 +23,7 @@ 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; @@ -46,8 +47,8 @@ public void run() { try { GHRelease rel = gravitLauncher.getLatestRelease(); Version relV = parseVer(rel.getTagName()); - if (Launcher.getVersion().major >= relV.major || Launcher.getVersion().minor >= relV.minor - || Launcher.getVersion().patch >= relV.patch || Launcher.getVersion().build >= relV.build) return; + if (VERSION.major >= relV.major || VERSION.minor >= relV.minor + || VERSION.patch >= relV.patch || VERSION.build >= relV.build) return; if (relV.release.equals(Type.STABLE) || relV.release.equals(Type.LTS)) { LogHelper.warning("New %s release: %s", relV.getReleaseStatus(), relV.getVersionString()); LogHelper.warning("You can download it: " + rel.getHtmlUrl().toString()); @@ -65,8 +66,7 @@ public void run() { private static final Pattern startingVerPattern = Pattern.compile("\\d+\\.\\d+\\.\\d+"); private static final Pattern pointPatternStriper = Pattern.compile("\\."); - private static Version parseVer(String tag) { - String relS = "4.3.4-stable"; + private static Version parseVer(String relS) { Matcher verMatcher = startingVerPattern.matcher(relS); if (!verMatcher.find()) return null; String[] ver = pointPatternStriper.split(relS.substring(verMatcher.start(), verMatcher.end())); @@ -78,14 +78,17 @@ private static Version parseVer(String tag) { private static Type findRelType(String substring) { if (substring.length() < 3 || substring.isEmpty()) return Type.UNKNOWN; String tS = substring; - while (tS.startsWith("-")) tS = tS.substring(1); - tS = tS.toLowerCase(Locale.ENGLISH); - if (tS.contains("lts")) return Type.LTS; - if (tS.contains("stable")) return Type.STABLE; - if (tS.contains("dev")) return Type.DEV; - if (tS.contains("alpha")) return Type.ALPHA; - if (tS.contains("beta")) return Type.BETA; - if (tS.contains("exp")) return Type.EXPERIMENTAL; - return Type.UNKNOWN; + if (tS.startsWith("-")) tS = tS.substring(1); + tS = tS.toUpperCase(Locale.ENGLISH); + Type t = Type.UNKNOWN; + try { + t = Type.valueOf(tS); + } catch (Throwable ign) { // ignore it + } + return t; + } + + public static void main(String[] args) { + System.out.println(parseVer("v3.4.5.6-stable").release); } } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java index 5d7858c6..8de9245a 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/profiles/ClientProfile.java @@ -10,7 +10,6 @@ import java.io.IOException; import java.net.InetSocketAddress; -import java.nio.file.Path; import java.util.*; public final class ClientProfile implements Comparable {