[FIX] Фикс багов Updater 1 часть - фикс копипаста.

This commit is contained in:
zaxar163 2019-01-22 21:25:51 +03:00
parent 9c34019446
commit 012870cf26
No known key found for this signature in database
GPG key ID: E3B309DD3852DE06
2 changed files with 16 additions and 14 deletions

View file

@ -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);
}
}

View file

@ -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<ClientProfile> {