mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Исправил скрипты сборки и пофиксил некоторые части Updater. (#164)
* [FIX] Вынес Timer в LaunchServer и Updater, ведь модули тоже могут его использовать. * [FIX] Updater исправлен парсинг типа версии и номера сборки.
This commit is contained in:
parent
a3e3089032
commit
8d979b3175
5 changed files with 13 additions and 11 deletions
|
@ -296,9 +296,9 @@ public static void main(String... args) throws Throwable {
|
|||
|
||||
// Updates and profiles
|
||||
private volatile List<ClientProfile> profilesList;
|
||||
|
||||
public volatile Map<String, SignedObjectHolder<HashedDir>> 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -28,4 +28,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
wrapper {
|
||||
distributionType = Wrapper.DistributionType.ALL
|
||||
}
|
||||
|
||||
defaultTasks 'build'
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -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
|
||||
|
|
|
@ -97,7 +97,7 @@ public enum Type {
|
|||
public static final Map<String, Type> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue