From 839c263955c68fc480899ed3554ff2eb86d453b2 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Sun, 23 Jun 2019 23:03:20 +0300 Subject: [PATCH] Replace SimpleJSON with Gson --- .../Slimefun/CSCoreLibSetup/CSCoreLibLoader.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/me/mrCookieSlime/Slimefun/CSCoreLibSetup/CSCoreLibLoader.java b/src/me/mrCookieSlime/Slimefun/CSCoreLibSetup/CSCoreLibLoader.java index a5c8a1672..ce5cce8e4 100644 --- a/src/me/mrCookieSlime/Slimefun/CSCoreLibSetup/CSCoreLibLoader.java +++ b/src/me/mrCookieSlime/Slimefun/CSCoreLibSetup/CSCoreLibLoader.java @@ -12,9 +12,10 @@ import java.net.URL; import java.net.URLConnection; import org.bukkit.plugin.Plugin; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; public class CSCoreLibLoader { @@ -62,9 +63,11 @@ public class CSCoreLibLoader { connection.setDoOutput(true); final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - final JSONArray array = (JSONArray) JSONValue.parse(reader.readLine()); - download = traceURL(((String) ((JSONObject) array.get(array.size() - 1)).get("downloadUrl")).replace("https:", "http:")); - file = new File("plugins/" + (String) ((JSONObject) array.get(array.size() - 1)).get("name") + ".jar"); + final JsonArray array = new JsonParser().parse(reader).getAsJsonArray(); + final JsonObject json = array.get(array.size() - 1).getAsJsonObject(); + + download = traceURL(json.get("downloadUrl").getAsString().replace("https:", "http:")); + file = new File("plugins/" + json.get("name").getAsString() + ".jar"); return true; } catch (IOException e) {