mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Merge pull request #158 from GravitLauncher/feature/checkUpd
[FEATURE] Уведомление о latest релизе на github.
This commit is contained in:
commit
7e8e332891
5 changed files with 61 additions and 5 deletions
|
@ -44,9 +44,10 @@ pack project(':libLauncher')
|
|||
bundle 'org.fusesource.jansi:jansi:1.17.1'
|
||||
bundle 'commons-io:commons-io:2.6'
|
||||
bundle 'commons-codec:commons-codec:1.11'
|
||||
bundle 'org.javassist:javassist:3.23.1-GA'
|
||||
bundle 'org.javassist:javassist:3.24.1-GA'
|
||||
bundle 'io.netty:netty-all:4.1.32.Final'
|
||||
|
||||
bundle 'org.kohsuke:github-api:1.95'
|
||||
|
||||
bundle 'org.slf4j:slf4j-simple:1.7.25'
|
||||
bundle 'org.slf4j:slf4j-api:1.7.25'
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ public static final class Config {
|
|||
|
||||
public String startScript;
|
||||
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
@ -289,6 +288,8 @@ public static void main(String... args) throws Throwable {
|
|||
|
||||
public volatile Map<String, SignedObjectHolder<HashedDir>> updatesDirMap;
|
||||
|
||||
public final Updater updater;
|
||||
|
||||
public static Gson gson;
|
||||
public static GsonBuilder gsonBuilder;
|
||||
|
||||
|
@ -439,6 +440,8 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
|
||||
// post init modules
|
||||
modulesManager.postInitModules();
|
||||
// start updater
|
||||
this.updater = new Updater(this);
|
||||
}
|
||||
|
||||
public static void initGson() {
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package ru.gravit.launchserver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.kohsuke.github.GHRelease;
|
||||
import org.kohsuke.github.GHRepository;
|
||||
import org.kohsuke.github.GitHub;
|
||||
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
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 final Timer taskPool;
|
||||
private final GHRepository gravitLauncher;
|
||||
private GHRelease parenRel = null;
|
||||
|
||||
public Updater(LaunchServer srv) {
|
||||
this.taskPool = new Timer("Updater thread", true);
|
||||
|
||||
GHRepository gravitLauncherTmp = null;
|
||||
try {
|
||||
gravitLauncherTmp = GitHub.connectAnonymously().getOrganization("GravitLauncher").getRepository("Launcher");
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
this.gravitLauncher = gravitLauncherTmp;
|
||||
|
||||
run();
|
||||
taskPool.schedule(this, new Date(System.currentTimeMillis()+period), period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
GHRelease rel = gravitLauncher.getLatestRelease();
|
||||
if (rel.equals(parenRel)) return;
|
||||
LogHelper.warning("Latest release: %s", rel.getName());
|
||||
LogHelper.warning("It`s published at: " + DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(rel.getPublished_at().getTime()), ZoneId.systemDefault())));
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,6 @@
|
|||
import java.lang.invoke.MethodType;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Collections;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class ServerAgent {
|
||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit 38e11640ce4a4ed3e9745718db02a888770a22bb
|
||||
Subproject commit 53106ee20700cb73ad65fd7dddf69b0d0b766f4c
|
Loading…
Reference in a new issue