From 80927417f2169adefad0af4ae970e6843181ef01 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Wed, 6 Mar 2013 22:20:11 +0100 Subject: [PATCH] Fix the update checker Now it's able to parse x.x.x-type-bxxx and x.x.x-bxxx --- .../java/com/gmail/nossr50/util/UpdateChecker.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/UpdateChecker.java b/src/main/java/com/gmail/nossr50/util/UpdateChecker.java index ea57f3ea9..3ff13d750 100644 --- a/src/main/java/com/gmail/nossr50/util/UpdateChecker.java +++ b/src/main/java/com/gmail/nossr50/util/UpdateChecker.java @@ -43,12 +43,18 @@ public class UpdateChecker { jo = (JSONObject) jo.get("versions"); newVersion = (String) jo.get("version"); - String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]"); - String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "").split("[.]|[b]"); + String[] oldTokens = version.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b"); + String[] newTokens = newVersion.replaceAll("(?i)(-)(.+?)(-)", "-").split("[.]|-b"); for (int i = 0; i < 4; i++) { Integer newVer = Integer.parseInt(newTokens[i]); - Integer oldVer = Integer.parseInt(oldTokens[i]); + Integer oldVer; + try { + oldVer = Integer.parseInt(oldTokens[i]); + } + catch (NumberFormatException e) { + oldVer = 0; + } if (oldVer < newVer) { isr.close(); return true;