net.minecraftforge.fml.common.versioning.ComparableVersion Java Examples
The following examples show how to use
net.minecraftforge.fml.common.versioning.ComparableVersion.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CCUpdateChecker.java From CodeChickenCore with MIT License | 6 votes |
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; } }); }
Example #2
Source File: VersionChecker.java From LunatriusCore with MIT License | 6 votes |
public Map<ComparableVersion, String> getAllChanges() { final LinkedHashMap<ComparableVersion, String> changes = new LinkedHashMap<ComparableVersion, String>(); if (this.builds != null) { Collections.sort(this.builds, new Comparator<BuildData>() { @Override public int compare(final BuildData a, final BuildData b) { return b.getVersion().compareTo(a.getVersion()); } }); for (final BuildData build : this.builds) { changes.put(build.getVersion(), build.getChanges()); } return changes; } if (this.latest != null) { changes.put(this.latest.getVersion(), this.latest.getChanges()); return changes; } return changes; }
Example #3
Source File: DepLoader.java From CodeChickenCore with MIT License | 5 votes |
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; } }
Example #4
Source File: ForgeVersionCheck.java From LunatriusCore with MIT License | 5 votes |
public static ForgeVersion.Status getStatus(final ComparableVersion versionRemote, final ComparableVersion versionLocal) { final int diff = versionRemote.compareTo(versionLocal); if (diff == 0) { return ForgeVersion.Status.UP_TO_DATE; } if (diff > 0) { return ForgeVersion.Status.OUTDATED; } return ForgeVersion.Status.AHEAD; }
Example #5
Source File: ForgeVersionCheck.java From LunatriusCore with MIT License | 5 votes |
public static void notify(final ModContainer container, final ForgeVersion.Status status, final ComparableVersion target, final Map<ComparableVersion, String> changes, final String url) { try { final Map<ModContainer, ForgeVersion.CheckResult> versionMap = getVersionMap(); final ForgeVersion.CheckResult checkResult = getCheckResult(status, target, changes, url); if (versionMap != null && checkResult != null) { versionMap.put(container, checkResult); } } catch (final Throwable t) { Reference.logger.error("Failed to notify Forge!", t); } }
Example #6
Source File: ForgeVersionCheck.java From LunatriusCore with MIT License | 5 votes |
private static ForgeVersion.CheckResult getCheckResult(final ForgeVersion.Status status, final ComparableVersion target, final Map<ComparableVersion, String> changes, final String url) throws ReflectiveOperationException { try { final Constructor<?> constructor = ForgeVersion.CheckResult.class.getDeclaredConstructor(ForgeVersion.Status.class, ComparableVersion.class, Map.class, String.class); constructor.setAccessible(true); return (ForgeVersion.CheckResult) constructor.newInstance(status, target, changes, url); } catch (final Throwable t) { Reference.logger.error("Failed to construct the CheckResult object!", t); } return null; }
Example #7
Source File: Updater.java From SkyblockAddons with MIT License | 4 votes |
/** * Processes the update checker result from the Forge Update Checker and sets the correct message to be displayed. */ public void processUpdateCheckResult() { SkyblockAddons main = SkyblockAddons.getInstance(); ComparableVersion current = new ComparableVersion(SkyblockAddons.VERSION); boolean isCurrentBeta = SkyblockAddons.VERSION.contains("b"); ComparableVersion latest = new ComparableVersion(isCurrentBeta ? main.getOnlineData().getLatestBeta() : main.getOnlineData().getLatestVersion()); main.getLogger().info("Checking to see if an update is available. Current version is "+current.toString()+". Latest version is "+latest.toString()); ForgeVersion.Status status; int versionDifference = latest.compareTo(current); if (versionDifference == 0) { status = UP_TO_DATE; } else if (versionDifference < 0) { status = AHEAD; } else { status = OUTDATED; } if (status == ForgeVersion.Status.OUTDATED) { hasUpdate = true; String currentVersion = current.toString(); String latestVersion = latest.toString(); main.getLogger().info("Found an update: "+latestVersion); try { Matcher currentMatcher = VERSION_PATTERN.matcher(currentVersion); Matcher latestMatcher = VERSION_PATTERN.matcher(latestVersion); // Its a patch if the major & minor numbers are the same & the player isn't upgrading out of a beta. if (currentMatcher.matches() && latestMatcher.matches() && currentMatcher.group("major").equals(latestMatcher.group("major")) && currentMatcher.group("minor").equals(latestMatcher.group("minor")) && !(currentVersion.contains("beta") && !latestVersion.contains("beta"))) { isPatch = true; } } catch (Exception ex) { ex.printStackTrace(); main.getLogger().warn("Couldn't parse update version numbers... This shouldn't affect too much."); } if (isPatch) { messageToRender = Message.UPDATE_MESSAGE_PATCH.getMessage(latestVersion); } else { messageToRender = Message.UPDATE_MESSAGE_MAJOR.getMessage(latestVersion); } } }
Example #8
Source File: VersionChecker.java From LunatriusCore with MIT License | 4 votes |
public ComparableVersion getVersion() { return new ComparableVersion(this.version); }