Changed to Gson in code as well

This commit is contained in:
Norbi Peti 2016-09-10 20:15:08 +02:00
parent a4356e884d
commit 6228d5d7d8

View file

@ -11,15 +11,18 @@ import java.util.List;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.json.JSONArray; import org.json.simple.JSONObject;
import org.json.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; import buttondevteam.bucket.MainPlugin;
public final class TBMCCoreAPI { public final class TBMCCoreAPI {
/** /**
* Updates or installs the specified plugin. The plugin JAR filename must * Updates or installs the specified plugin. The plugin JAR filename must match the plugin's repository name.
* match the plugin's repository name.
* *
* @param name * @param name
* The plugin's repository/JAR name. * The plugin's repository/JAR name.
@ -48,10 +51,10 @@ public final class TBMCCoreAPI {
List<String> ret = new ArrayList<>(); List<String> ret = new ArrayList<>();
try { try {
String resp = DownloadString("https://api.github.com/orgs/TBMCPlugins/repos"); String resp = DownloadString("https://api.github.com/orgs/TBMCPlugins/repos");
JSONArray arr = new JSONArray(resp); JsonArray arr = new JsonParser().parse(resp).getAsJsonArray();
for (Object obj : arr) { for (JsonElement obj : arr) {
JSONObject jobj = (JSONObject) obj; JsonObject jobj = obj.getAsJsonObject();
ret.add(jobj.getString("name")); ret.add(jobj.get("name").getAsString());
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();