customizable time interval for the UpdateChecker
This commit is contained in:
parent
9d0902f611
commit
6cbae613a3
@ -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;
|
||||
|
@ -48,18 +48,17 @@ public final class Main extends JavaPlugin {
|
||||
plugin = this;
|
||||
autor = plugin.getDescription().getAuthors();
|
||||
version = plugin.getDescription().getVersion();
|
||||
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
||||
new UpdateChecker(this, 12345).getVersion(ver -> {
|
||||
if (this.getDescription().getVersion().equals(version)) {
|
||||
if (Double.parseDouble(ver) < Double.parseDouble(version)) {
|
||||
send.console(prefix + " §4 §e-------------------");
|
||||
send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! §4This is a trial version! §eSome features may not be working as expected. Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
|
||||
send.console(prefix + " §4 §e-------------------");
|
||||
}
|
||||
}
|
||||
});
|
||||
Long long_;
|
||||
long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
||||
if (Util.getSnapshot()){
|
||||
send.console(prefix + " §eYou are running §4" + version + " §eof " + prefix + "§e! §4This is a trial version! §eSome features may not be working as expected. Please report all bugs here: http://dc.t2code.net §4UpdateChecker & bStats may be disabled!");
|
||||
send.console(prefix + " §4 §e-------------------");
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//send.console("§4 _|_|_|_|_| _|_| _|_|_| _| ");
|
||||
//send.console("§4 _| _| _| _| _|_| _|_|_| _|_| ");
|
||||
@ -109,6 +108,7 @@ public final class Main extends JavaPlugin {
|
||||
LanguagesCreate.langCreate();
|
||||
SelectLibConfig.onSelect();
|
||||
SelectLibMsg.onSelect(prefix);
|
||||
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
||||
|
||||
Metrics.Bstats(plugin, bstatsID);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
||||
|
@ -12,6 +12,7 @@ import java.io.IOException;
|
||||
public class ConfigCreate {
|
||||
|
||||
private static Boolean UpdateCheckOnJoin = true;
|
||||
private static Integer UpdateCheckTimeInterval = 60;
|
||||
private static Boolean Debug = false;
|
||||
private static String language = "english";
|
||||
|
||||
@ -38,7 +39,8 @@ public class ConfigCreate {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
Config.set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration);
|
||||
Config.set("Plugin.UpdateCheck.OnJoin", UpdateCheckOnJoin, yamlConfiguration);
|
||||
Config.set("Plugin.UpdateCheck.TimeInterval", UpdateCheckTimeInterval, yamlConfiguration);
|
||||
Config.set("Plugin.language", language, yamlConfiguration);
|
||||
|
||||
Config.set("BungeeCord.Enable", Bungee, yamlConfiguration);
|
||||
|
@ -9,6 +9,7 @@ public class SelectLibConfig {
|
||||
|
||||
|
||||
public static Boolean UpdateCheckOnJoin;
|
||||
public static Integer UpdateCheckTimeInterval;
|
||||
public static Boolean Debug;
|
||||
public static String language;
|
||||
public static Boolean InventoriesCloseByServerStop;
|
||||
@ -17,7 +18,8 @@ public class SelectLibConfig {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin");
|
||||
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheck.OnJoin");
|
||||
UpdateCheckTimeInterval = yamlConfiguration.getInt("Plugin.UpdateCheck.TimeInterval");
|
||||
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
|
||||
language = yamlConfiguration.getString("Plugin.language");
|
||||
InventoriesCloseByServerStop = yamlConfiguration.getBoolean("Player.Inventories.CloseByServerStop");
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user