Fix to support new mod.json format

dev/0.11
modmuss50 2018-05-15 11:58:51 +01:00
parent d13f33d0f3
commit f1a00533ad
1 changed files with 13 additions and 10 deletions

View File

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