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 java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class EntityLib {
|
||||
|
||||
|
@ -19,13 +18,7 @@ public final class EntityLib {
|
|||
platform.setupApi(settings);
|
||||
api = platform.getAPI();
|
||||
|
||||
if (api.getSettings().shouldCheckForUpdate()) {
|
||||
if (api.getSettings().isDebugMode()) {
|
||||
platform.getLogger().log(Level.INFO, "Checking for updates...");
|
||||
}
|
||||
|
||||
new GithubUpdater("Tofaa2", "EntityLib").checkForUpdates();
|
||||
}
|
||||
new GithubUpdater("Tofaa2", "EntityLib");
|
||||
}
|
||||
|
||||
public static Optional<EntityLibAPI<?>> getOptionalApi() {
|
||||
|
|
|
@ -27,15 +27,23 @@ public final class GithubUpdater {
|
|||
this.repo = repo;
|
||||
this.currentVersion = ELVersions.CURRENT;
|
||||
this.logger = EntityLib.getPlatform().getLogger();
|
||||
|
||||
if (EntityLib.getApi().getSettings().shouldCheckForUpdate()) {
|
||||
if (EntityLib.getApi().getSettings().isDebugMode()) {
|
||||
logger.log(Level.INFO, "Checking for updates...");
|
||||
}
|
||||
|
||||
checkForUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkForUpdates() {
|
||||
private void checkForUpdates() {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
PEVersion latestVersion = getLatestVersion();
|
||||
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.");
|
||||
} else if (currentVersion.isNewerThan(latestVersion)) {
|
||||
logger.log(Level.WARNING, "You are using an outdated version of EntityLib. Version: " + latestVersion + " is now available.");
|
||||
} else if (currentVersion.equals(latestVersion)) {
|
||||
logger.log(Level.INFO, "No EntityLib updates found.");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
|
Loading…
Reference in a new issue