From 6eb61b28f6297c53b4f22dd4efd309cd2922d4eb Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 7 Mar 2019 14:48:53 +1300 Subject: [PATCH] Compare numbers and fallback to string for updates --- .../disguise/utilities/UpdateChecker.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.java b/src/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.java index 799be435..01740244 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/UpdateChecker.java @@ -10,7 +10,6 @@ import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.Map; -import java.util.concurrent.TimeUnit; public class UpdateChecker { private final String resourceID; @@ -122,6 +121,20 @@ public class UpdateChecker { return false; } + // If both strings are numerical + if (cSplit[i].matches("[0-9]+") && nSplit[i].matches("[0-9]+")) { + int cInt = Integer.parseInt(cSplit[i]); + int nInt = Integer.parseInt(nSplit[i]); + + // Same version + if (cInt == nInt) { + continue; + } + + // Return if current version is inferior to new version + return cInt < nInt; + } + // String compare the versions, should perform the same as an int compare int compareResult = cSplit[i].compareTo(nSplit[i]);