public class FetchedUpdateable {
public final boolean auto; public final int severity; public final String displaySeverity; public final String display; public final String oldDisp; public final String url; public final int old; public final int version; public final int diff; public final String name; public boolean chatted = false;@SuppressWarnings("unchecked")
public FetchedUpdateable(IUpdateable mod) {
this.name = mod.getName();Yaml yaml = new Yaml();Map<String, Object> load = (Map<String, Object>) yaml.load(mod.getRemote()); this.auto = (Boolean) load.get("auto"); this.url = (String) load.get("url");List<Integer> severityL = (List<Integer>) load.get("severity");List<String> displayL = (List<String>) load.get("display");List<Integer> versionL = (List<Integer>) load.get("technical");HashMap<String, String> local = mod.getLocal(); this.old = Integer.valueOf(local.get("technical")); this.oldDisp = local.get("display"); int splitIndex = versionL.indexOf(this.old); this.version = versionL.get(versionL.size() - 1); this.display = displayL.get(versionL.size() - 1); this.severity = Util.max(Util.after(severityL, splitIndex)); this.displaySeverity = makeDisplayS(severity); this.diff = this.version - this.old;}
public FetchedUpdateable(IUpdateable mod, boolean auto, int severity, String display, String oldDisp, String url, int old, int version) {
this(auto, severity, makeDisplayS(severity),display, oldDisp, url, old, version, version - old, mod);}
public FetchedUpdateable(boolean auto, int severity, String displaySeverity, String display, String oldDisp, String url, int old, int version, int diff, IUpdateable mod) {
this(auto, severity, displaySeverity, display, oldDisp, url, old, version, diff, mod.getName());}
public FetchedUpdateable(boolean auto, int severity, String displaySeverity, String display, String oldDisp, String url, int old, int version, int diff, String modName) {
this.auto = auto; this.severity = severity; this.displaySeverity = displaySeverity; this.display = display; this.oldDisp = oldDisp; this.url = url; this.old = old; this.version = version; this.diff = diff; this.name = modName;}
protected static String makeDisplayS(int severity) {
if (severity < 2) {
return "Normal";} else if (severity < 3) {
return "Severe!";}
return "Critical!!";}
}