mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-14 15:26:54 +01:00
Check for update every 6 hours
This commit is contained in:
parent
fc6c34280c
commit
a49f4d41ec
@ -29,24 +29,27 @@ public class DisguiseListener implements Listener {
|
|||||||
permission = plugin.getConfig().getString("Permission");
|
permission = plugin.getConfig().getString("Permission");
|
||||||
if (plugin.getConfig().getBoolean("NotifyUpdate")) {
|
if (plugin.getConfig().getBoolean("NotifyUpdate")) {
|
||||||
currentVersion = plugin.getDescription().getVersion();
|
currentVersion = plugin.getDescription().getVersion();
|
||||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
|
Bukkit.getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
UpdateChecker updateChecker = new UpdateChecker();
|
UpdateChecker updateChecker = new UpdateChecker();
|
||||||
updateChecker.checkUpdate("v"
|
updateChecker.checkUpdate("v" + currentVersion);
|
||||||
+ Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion());
|
|
||||||
latestVersion = updateChecker.getLatestVersion();
|
latestVersion = updateChecker.getLatestVersion();
|
||||||
if (latestVersion != null) {
|
if (latestVersion != null) {
|
||||||
latestVersion = "v" + latestVersion;
|
latestVersion = "v" + latestVersion;
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
if (p.hasPermission(permission))
|
public void run() {
|
||||||
p.sendMessage(String.format(updateMessage, currentVersion, latestVersion));
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
if (p.hasPermission(permission))
|
||||||
|
p.sendMessage(String.format(updateMessage, currentVersion, latestVersion));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.print(String.format("[LibsDisguises] Failed to check for update: %s", ex.getMessage()));
|
System.out.print(String.format("[LibsDisguises] Failed to check for update: %s", ex.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, 0, (20 * 60 * 60 * 6)); // Check every 6 hours
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user