LagAssist is a plugin that provides tools to prevent, analyse or resolve lag.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

package cx.sfy.LagAssist.updater;
import cx.sfy.LagAssist.Main;
public class UpdateCondition {
private static int mindownloads = 0;
private static int minlikes = 0;
private static float minrating = 0;
private static boolean unsafe = true;
private static VersionComparator vc = new VersionComparator();
public static void Enabler() {
unsafe = Main.config.getBoolean("smart-updater.announce.unsafe");
minlikes = Main.config.getInt("smart-updater.announce.min-likes");
mindownloads = Main.config.getInt("smart-updater.announce.min-downloads");
minrating = (float) Main.config.getDouble("smart-updater.announce.min-rating");
}
public static boolean shouldUpgrade(UpdateInfo info) {
if (info.isUnsafe() && !unsafe) {
return false;
}
String currentver = Main.p.getDescription().getVersion();
String newver = info.getVersion();
if (newver == null || currentver == null) {
return false;
}
if (vc.compare(currentver, newver) > 0) {
return false;
}
if (info.getLikes() < minlikes) {
return false;
}
if (info.getDownloads() < mindownloads) {
return false;
}
if (info.getRating() < minrating) {
return false;
}
return true;
}
}