Fixed "Not a JSON Array", closes #49

This commit is contained in:
stijnb1234 2020-07-05 21:31:34 +02:00
parent 08c26540c6
commit 579b2d7e28

View file

@ -1,6 +1,5 @@
package nl.SBDeveloper.V10Lift.sbutils; package nl.SBDeveloper.V10Lift.sbutils;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -104,13 +103,10 @@ public class UpdateManager {
} }
in.close(); in.close();
JsonParser parser = new JsonParser();
if (type == CheckType.SPIGOT) { if (type == CheckType.SPIGOT) {
JsonArray array = parser.parse(response.toString()).getAsJsonArray(); version = response.toString();
version = array.get(0).getAsJsonObject().get("name").getAsString();
} else if (type == CheckType.SBDPLUGINS) { } else if (type == CheckType.SBDPLUGINS) {
JsonParser parser = new JsonParser();
JsonObject object = parser.parse(response.toString()).getAsJsonObject(); JsonObject object = parser.parse(response.toString()).getAsJsonObject();
version = object.get("data").getAsJsonObject().get("version").getAsString(); version = object.get("data").getAsJsonObject().get("version").getAsString();