customizable time interval for the UpdateChecker

This commit is contained in:
2021-12-31 02:36:03 +01:00
parent 9d0902f611
commit 6cbae613a3
10 changed files with 21 additions and 16 deletions

View File

@@ -82,9 +82,12 @@ public class UpdateAPI {
private static Boolean noUpdate = true;
public static void onUpdateCheck(Plugin plugin, String Prefix, String Spigot, int SpigotID, String Discord) {
onUpdateCheck(plugin, Prefix, Spigot, SpigotID, Discord, 60);
}
public static void onUpdateCheck(Plugin plugin, String Prefix, String Spigot, int SpigotID, String Discord, Integer timeInMin) {
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
public void run() {
(new UpdateAPI((JavaPlugin) plugin, SpigotID)).getVersion((update_version) -> {
UpdateObject update = new UpdateObject(
plugin.getName(),
@@ -92,7 +95,6 @@ public class UpdateAPI {
update_version
);
UpdateAPI.PluginVersionen.put(plugin.getName(), update);
if (!plugin.getDescription().getVersion().equalsIgnoreCase(update_version)) {
noUpdate = true;
new BukkitRunnable() {
@@ -102,7 +104,6 @@ public class UpdateAPI {
}
}.runTaskLater(plugin, 600L);
} else {
if (noUpdate) {
send.console(Prefix + " §2No update found.");
noUpdate = false;
@@ -110,7 +111,7 @@ public class UpdateAPI {
}
}, Prefix, plugin.getDescription().getVersion());
}
}, 0L, 20 * 60 * 60L);
}, 0L, timeInMin * 60 * 20L);
}
private JavaPlugin plugin;