Skip to content

Commit

Permalink
Added update checker to extra thread for faster boot times
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Jul 8, 2019
1 parent 74b17f7 commit 19434f9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/net/Lenni0451/SpigotPluginManager/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ public void onEnable() {
this.getCommand("pluginmanager").setAliases(Arrays.asList("pm"));
this.getCommand("pluginmanager").setTabCompleter(new PluginManager_TabComplete());

try {
String newestVersion = DownloadUtils.getNewestVersion();
if(!newestVersion.equals(this.getDescription().getVersion())) {
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "A new update of PluginManager is available §e(" + this.getDescription().getVersion() + " -> " + newestVersion + ").");
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "You can download it here: §6https://github.com/Lenni0451/SpigotPluginManager/releases/latest/download/PluginManager.jar");
} else {
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "You are using the latest version of PluginManager.");
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
try {
String newestVersion = DownloadUtils.getNewestVersion();
if(!newestVersion.equals(this.getDescription().getVersion())) {
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "A new update of PluginManager is available §e(" + this.getDescription().getVersion() + " -> " + newestVersion + ").");
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "You can download it here: §6https://github.com/Lenni0451/SpigotPluginManager/releases/latest/download/PluginManager.jar");
} else {
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "You are using the latest version of PluginManager.");
}
} catch (Throwable e) {
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "§cCould not check for updates.");
}
} catch (Throwable e) {
Logger.sendPrefixMessage(Bukkit.getConsoleSender(), "§cCould not check for updates.");
}
});
}

}

0 comments on commit 19434f9

Please sign in to comment.