Fixed and improved the GithubUpdater
This commit is contained in:
parent
7a313da975
commit
cb4ac1031f
2 changed files with 12 additions and 11 deletions
|
@ -5,7 +5,6 @@ import me.tofaa.entitylib.utils.ELVersions;
|
||||||
import me.tofaa.entitylib.utils.GithubUpdater;
|
import me.tofaa.entitylib.utils.GithubUpdater;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public final class EntityLib {
|
public final class EntityLib {
|
||||||
|
|
||||||
|
@ -19,13 +18,7 @@ public final class EntityLib {
|
||||||
platform.setupApi(settings);
|
platform.setupApi(settings);
|
||||||
api = platform.getAPI();
|
api = platform.getAPI();
|
||||||
|
|
||||||
if (api.getSettings().shouldCheckForUpdate()) {
|
new GithubUpdater("Tofaa2", "EntityLib");
|
||||||
if (api.getSettings().isDebugMode()) {
|
|
||||||
platform.getLogger().log(Level.INFO, "Checking for updates...");
|
|
||||||
}
|
|
||||||
|
|
||||||
new GithubUpdater("Tofaa2", "EntityLib").checkForUpdates();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<EntityLibAPI<?>> getOptionalApi() {
|
public static Optional<EntityLibAPI<?>> getOptionalApi() {
|
||||||
|
|
|
@ -27,15 +27,23 @@ public final class GithubUpdater {
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.currentVersion = ELVersions.CURRENT;
|
this.currentVersion = ELVersions.CURRENT;
|
||||||
this.logger = EntityLib.getPlatform().getLogger();
|
this.logger = EntityLib.getPlatform().getLogger();
|
||||||
|
|
||||||
|
if (EntityLib.getApi().getSettings().shouldCheckForUpdate()) {
|
||||||
|
if (EntityLib.getApi().getSettings().isDebugMode()) {
|
||||||
|
logger.log(Level.INFO, "Checking for updates...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkForUpdates() {
|
checkForUpdates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkForUpdates() {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
PEVersion latestVersion = getLatestVersion();
|
PEVersion latestVersion = getLatestVersion();
|
||||||
if (currentVersion.isOlderThan(latestVersion)) {
|
if (currentVersion.isOlderThan(latestVersion)) {
|
||||||
logger.log(Level.WARNING, "You are using an outdated version of EntityLib. Please take a look at the Github releases page.");
|
logger.log(Level.WARNING, "You are using an outdated version of EntityLib. Version: " + latestVersion + " is now available.");
|
||||||
} else if (currentVersion.isNewerThan(latestVersion)) {
|
} else if (currentVersion.equals(latestVersion)) {
|
||||||
logger.log(Level.INFO, "No EntityLib updates found.");
|
logger.log(Level.INFO, "No EntityLib updates found.");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|
Loading…
Reference in a new issue