fix update checker shutdown errors
This commit is contained in:
parent
e893beb22f
commit
3bfea0a004
2 changed files with 5 additions and 1 deletions
|
@ -149,7 +149,7 @@ public class ZNpcsPlus {
|
||||||
if (configManager.getConfig().checkForUpdates()) {
|
if (configManager.getConfig().checkForUpdates()) {
|
||||||
UpdateChecker updateChecker = new UpdateChecker(getDescription());
|
UpdateChecker updateChecker = new UpdateChecker(getDescription());
|
||||||
scheduler.runDelayedTimerAsync(updateChecker, 5L, 6000L);
|
scheduler.runDelayedTimerAsync(updateChecker, 5L, 6000L);
|
||||||
shutdownTasks.add(updateChecker::cancel);
|
shutdownTasks.add(updateChecker::shutdown);
|
||||||
pluginManager.registerEvents(new UpdateNotificationListener(this, adventure, updateChecker, scheduler), bootstrap);
|
pluginManager.registerEvents(new UpdateNotificationListener(this, adventure, updateChecker, scheduler), bootstrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,10 @@ public class UpdateChecker extends BukkitRunnable {
|
||||||
logger.warning("Download it at " + UpdateChecker.DOWNLOAD_LINK);
|
logger.warning("Download it at " + UpdateChecker.DOWNLOAD_LINK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
if (getTaskId() != -1) cancel();
|
||||||
|
}
|
||||||
|
|
||||||
private int versionToNumber(String version) {
|
private int versionToNumber(String version) {
|
||||||
int num = Integer.parseInt(version.replaceAll("[^0-9]", ""));
|
int num = Integer.parseInt(version.replaceAll("[^0-9]", ""));
|
||||||
if (version.toLowerCase().contains("snapshot")) num -= 1;
|
if (version.toLowerCase().contains("snapshot")) num -= 1;
|
||||||
|
|
Loading…
Reference in a new issue