Refactor[modDetail]: Move mc version auto addition to model constructor

This commit is contained in:
Mathias Boulay 2023-08-15 19:43:14 +02:00 committed by ArtDev
parent ce5ed86515
commit 23b02cca4c
2 changed files with 6 additions and 3 deletions

View File

@ -77,9 +77,6 @@ public class ModrinthApi implements ModpackApi{
names[i] = version.get("name").getAsString();
mcNames[i] = version.get("game_versions").getAsJsonArray().get(0).getAsString();
urls[i] = version.get("files").getAsJsonArray().get(0).getAsJsonObject().get("url").getAsString();
if (!names[i].contains(mcNames[i]))
names[i] += " - " + mcNames[i];
}
return new ModDetail(item, names, mcNames, urls);

View File

@ -15,6 +15,12 @@ public class ModDetail extends ModItem {
this.versionNames = versionNames;
this.mcVersionNames = mcVersionNames;
this.versionUrls = versionUrls;
// Add the mc version to the version model
for (int i=0; i<versionNames.length; i++){
if (!versionNames[i].contains(mcVersionNames[i]))
versionNames[i] += " - " + mcVersionNames[i];
}
}
@NonNull