mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] Уведомление о latest релизе на github.
This commit is contained in:
parent
ec0948594d
commit
237a2a2f92
4 changed files with 58 additions and 4 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;
|
||||
}
|
||||
|
@ -439,6 +438,8 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
|
||||
// post init modules
|
||||
modulesManager.postInitModules();
|
||||
// start 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 {
|
||||
|
|
Loading…
Reference in a new issue