From c6903d504416270975e9ba8cbef59e6d91974378 Mon Sep 17 00:00:00 2001 From: Nick Minkler Date: Tue, 24 Dec 2013 13:23:35 -0800 Subject: [PATCH] Fix regexp, period needs to be escaped. Use better exception handling. --- src/net/milkbowl/vault/Vault.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/net/milkbowl/vault/Vault.java b/src/net/milkbowl/vault/Vault.java index 1fc7510..daf0d85 100644 --- a/src/net/milkbowl/vault/Vault.java +++ b/src/net/milkbowl/vault/Vault.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.Collection; @@ -526,9 +527,9 @@ public class Vault extends JavaPlugin { } } - public double updateCheck(double currentVersion) throws Exception { - final URL url = new URL("https://api.curseforge.com/servermods/files?projectids=33184"); + public double updateCheck(double currentVersion) { try { + URL url = new URL("https://api.curseforge.com/servermods/files?projectids=33184"); URLConnection conn = url.openConnection(); conn.setReadTimeout(5000); conn.addRequestProperty("User-Agent", "Vault Update Checker"); @@ -542,12 +543,12 @@ public class Vault extends JavaPlugin { return currentVersion; } // Pull the last version from the JSON - String version = ((String) ((JSONObject) array.get(array.size() - 1)).get("name")).replace("Vault", "").replaceFirst(".", "").trim(); + String version = ((String) ((JSONObject) array.get(array.size() - 1)).get("name")).replace("Vault", "").replaceFirst("\\.", "").trim(); return Double.valueOf(version); - } - catch (Exception localException) { - // Dump the stack trace - localException.printStackTrace(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } return currentVersion; }