fix update checker shutdown errors

This commit is contained in:
Pyrbu 2023-12-30 20:35:33 +01:00
parent e893beb22f
commit 3bfea0a004
2 changed files with 5 additions and 1 deletions

@ -149,7 +149,7 @@ public class ZNpcsPlus {
if (configManager.getConfig().checkForUpdates()) {
UpdateChecker updateChecker = new UpdateChecker(getDescription());
scheduler.runDelayedTimerAsync(updateChecker, 5L, 6000L);
shutdownTasks.add(updateChecker::cancel);
shutdownTasks.add(updateChecker::shutdown);
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);
}
public void shutdown() {
if (getTaskId() != -1) cancel();
}
private int versionToNumber(String version) {
int num = Integer.parseInt(version.replaceAll("[^0-9]", ""));
if (version.toLowerCase().contains("snapshot")) num -= 1;