From 6228d5d7d8a7ed34ad03af981093f6ff716bcc80 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 10 Sep 2016 20:15:08 +0200 Subject: [PATCH] Changed to Gson in code as well --- .../bucket/core/TBMCCoreAPI.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/buttondevteam/bucket/core/TBMCCoreAPI.java b/src/buttondevteam/bucket/core/TBMCCoreAPI.java index cfd7cac..c44de54 100644 --- a/src/buttondevteam/bucket/core/TBMCCoreAPI.java +++ b/src/buttondevteam/bucket/core/TBMCCoreAPI.java @@ -11,15 +11,18 @@ import java.util.List; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; -import org.json.JSONArray; -import org.json.JSONObject; +import org.json.simple.JSONObject; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import buttondevteam.bucket.MainPlugin; public final class TBMCCoreAPI { /** - * Updates or installs the specified plugin. The plugin JAR filename must - * match the plugin's repository name. + * Updates or installs the specified plugin. The plugin JAR filename must match the plugin's repository name. * * @param name * The plugin's repository/JAR name. @@ -48,10 +51,10 @@ public final class TBMCCoreAPI { List ret = new ArrayList<>(); try { String resp = DownloadString("https://api.github.com/orgs/TBMCPlugins/repos"); - JSONArray arr = new JSONArray(resp); - for (Object obj : arr) { - JSONObject jobj = (JSONObject) obj; - ret.add(jobj.getString("name")); + JsonArray arr = new JsonParser().parse(resp).getAsJsonArray(); + for (JsonElement obj : arr) { + JsonObject jobj = obj.getAsJsonObject(); + ret.add(jobj.get("name").getAsString()); } } catch (Exception e) { e.printStackTrace();