1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Replace SimpleJSON with Gson

This commit is contained in:
SoSeDiK 2019-06-23 23:03:20 +03:00
parent 8f173ea76c
commit 839c263955

View File

@ -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) {