OpenInv/src/main/java/com/lishid/openinv/utils/UpdateManager.java

35 lines
1.2 KiB
Java
Raw Normal View History

package com.lishid.openinv.utils;
import java.io.File;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.utils.Updater.UpdateResult;
2013-12-07 04:44:40 -05:00
public class UpdateManager {
public Updater updater;
2013-12-07 04:44:40 -05:00
public void Initialize(OpenInv plugin, File file) {
updater = new Updater(plugin, 31432, file);
// Create task to update
2013-12-07 04:44:40 -05:00
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
@Override
2013-12-07 04:44:40 -05:00
public void run() {
// Check for updates
2013-12-07 04:44:40 -05:00
if (OpenInv.GetCheckForUpdates()) {
UpdateResult result = updater.update();
if (result != UpdateResult.NO_UPDATE) {
if (result == UpdateResult.SUCCESS) {
OpenInv.log("Update found! Downloaded new version.");
OpenInv.log("This behaviour can be disabled in the config.yml");
}
else {
OpenInv.log("Update failed, reason: " + result.toString());
}
}
}
}
}, 0, 20 * 60 * 1000); // Update every once a while
}
}