public VersionedFile(String filename, Pattern pattern) { this.pattern = pattern; this.filename = filename; Matcher m = pattern.matcher(filename); if (m.matches()) { name = m.group(1); version = new ComparableVersion(m.group(2)); } else { name = null; version = null; } }
public static void updateCheck(final String mod, final String version) { updateCheck("http://www.chickenbones.net/Files/notification/version.php?" + "version=" + mcVersion() + "&" + "file=" + mod, new Function<String, Void>() { @Override public Void apply(String ret) { if (!ret.startsWith("Ret: ")) { CodeChickenCorePlugin.logger.error("Failed to check update for " + mod + " returned: " + ret); return null; } ComparableVersion newversion = new ComparableVersion(ret.substring(5)); if (newversion.compareTo(new ComparableVersion(version)) > 0) addUpdateMessage("Version " + newversion + " of " + mod + " is available"); return null; } }); }
public VersionedFile(String filename, Pattern pattern) { this.pattern = pattern; this.filename = filename; Matcher m = pattern.matcher(filename); if(m.matches()) { name = m.group(1); version = new ComparableVersion(m.group(2)); } else { name = null; version = null; } }
private void check(ModContainer modContainer) { try { ComparableVersion current = new ComparableVersion(modContainer.getVersion()); URL url = new URL(NOConstants.URL_MAVEN + modContainer.getMod().getClass().getCanonicalName().replace('.', '/') + "/maven-metadata.xml"); MetadataXpp3Reader metadataXpp3Reader = new MetadataXpp3Reader(); Metadata metadata = metadataXpp3Reader.read(url.openStream()); ComparableVersion latest = null; for (String versionString : metadata.getVersioning().getVersions()) { if (versionString.contains(MCVERSION + "-")) { versionString = versionString.replace(MCVERSION + "-", ""); ComparableVersion version = new ComparableVersion(versionString); if (latest == null || version.compareTo(latest) > 0) latest = version; } } if (latest != null && latest.compareTo(current) > 0) modsToUpdate.put(modContainer, latest.toString()); } catch (Exception ignored) { // We don't really care, a lot of things can go wrong... NucleumOmnium.getLogger().info("Something went wrong when version checking " + modContainer.getModId() + ", check manually."); } }
private boolean checkIsNewer(String current, String received) { return new ComparableVersion(received).compareTo(new ComparableVersion(current)) > 0; }
public ComparableVersion getVersion() { return file.getVersion(); }
public ComparableVersion getVersion() { return version; }