From f1a00533ad4209161746249c3beb0ca1ba75b9fa Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Tue, 15 May 2018 11:58:51 +0100 Subject: [PATCH] Fix to support new mod.json format --- .../net/fabricmc/loom/AbstractPlugin.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/fabricmc/loom/AbstractPlugin.java b/src/main/java/net/fabricmc/loom/AbstractPlugin.java index 6ea6fbcc..a11bf1bd 100644 --- a/src/main/java/net/fabricmc/loom/AbstractPlugin.java +++ b/src/main/java/net/fabricmc/loom/AbstractPlugin.java @@ -26,6 +26,7 @@ package net.fabricmc.loom; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import net.fabricmc.loom.task.DownloadTask; @@ -273,17 +274,19 @@ public class AbstractPlugin implements Plugin { Gson gson = new Gson(); try { JsonElement jsonElement = gson.fromJson(new FileReader(modJson), JsonElement.class); - JsonObject jsonObject = jsonElement.getAsJsonObject(); - if ((extension.version == null || extension.version.isEmpty()) && jsonObject.has("version")) { - project.setVersion(jsonObject.get("version").getAsString()); + JsonArray jsonArray = jsonElement.getAsJsonArray(); + for (int i = 0; i < jsonArray.size(); i++) { + JsonObject jsonObject = jsonArray.get(i).getAsJsonObject(); + if ((extension.version == null || extension.version.isEmpty()) && jsonObject.has("version")) { + project.setVersion(jsonObject.get("version").getAsString()); + } + if (jsonObject.has("group")) { + project.setGroup(jsonObject.get("group").getAsString()); + } + if (jsonObject.has("description")) { + project.setDescription(jsonObject.get("description").getAsString()); + } } - if (jsonObject.has("group")) { - project.setGroup(jsonObject.get("group").getAsString()); - } - if (jsonObject.has("description")) { - project.setDescription(jsonObject.get("description").getAsString()); - } - //TODO load deps } catch (FileNotFoundException e) { //This wont happen as we have checked for it