[Bungee] Fixed a small performance bug: If the update check interval was set to 0, it could crash the server and cause spam in the console both to the update check server of T2Code.

This commit is contained in:
JaTiTV 2023-05-10 21:09:27 +02:00
parent 66dc27483b
commit 709bd16317
2 changed files with 5 additions and 2 deletions

View File

@ -49,6 +49,10 @@ public class T2CBupdateAPI {
private static String pluginVersion;
public static void onUpdateCheckTimer(Plugin plugin, String prefix, String discord, Integer spigotID, String url) {
Integer finalInterval;
if (T2CBlibConfig.getUpdateTimer() < 1){
finalInterval = 1;
} else finalInterval = T2CBlibConfig.getUpdateTimer();
ProxyServer.getInstance().getScheduler().schedule(plugin, new Runnable() {
public void run() {
if (T2CBlibConfig.getUpdateCheckFullDisable()) return;
@ -74,6 +78,6 @@ public class T2CBupdateAPI {
}
}, pluginVersion, spigotID, url);
}
}, 0, T2CBlibConfig.getUpdateTimer() * 60 * 20L, TimeUnit.SECONDS);
}, 0, finalInterval * 60 * 20L, TimeUnit.SECONDS);
}
}

View File

@ -3,7 +3,6 @@ package net.t2code.t2codelib.BUNGEE.api.update;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Plugin;
import net.t2code.t2codelib.BUNGEE.system.config.T2CBlibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
import net.t2code.t2codelib.T2CupdateObject;
import net.t2code.t2codelib.T2CupdateWebData;
import org.json.JSONArray;