Skip to content

Commit

Permalink
Update instances.json on mods update
Browse files Browse the repository at this point in the history
  • Loading branch information
The Judge committed Sep 23, 2024
1 parent 0157f9d commit a4632e4
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions src/main/java/pojlib/util/json/MinecraftInstances.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,31 @@ private void removeOldMods(ModsJson oldMods, ModsJson newMods) {
}

private void updateModByType(List<ProjectInfo> newMods) throws IOException {
for(ProjectInfo extMod : extProjects) {
boolean manual = true;
for(ProjectInfo newMod : newMods) {
if(!extMod.slug.equals(newMod.slug)) {
continue;
}
manual = false;
File mod = new File(gameDir + (newMod.type.equals("mod") ? "/mods" : "/resourcepacks"), newMod.slug + ".jar");
if(!mod.exists() || !extMod.version.equals(newMod.version)) {
DownloadUtils.downloadFile(newMod.download_link, mod);
break;
}
}
if(manual) {
File mod = new File(gameDir + (extMod.type.equals("mod") ? "/mods" : "/resourcepacks"), extMod.slug + ".jar");
if(!mod.exists()) {
DownloadUtils.downloadFile(extMod.download_link, mod);
break;
}
}
}
ArrayList<ProjectInfo> newExtMods = new ArrayList<>();
for(ProjectInfo extMod : extProjects) {
boolean manual = true;
for(ProjectInfo newMod : newMods) {
if(!extMod.slug.equals(newMod.slug)) {
continue;
}
manual = false;
File mod = new File(gameDir + (newMod.type.equals("mod") ? "/mods" : "/resourcepacks"), newMod.slug + ".jar");
if(!mod.exists() || !extMod.version.equals(newMod.version)) {
DownloadUtils.downloadFile(newMod.download_link, mod);
extMod = newMod;
break;
}
}
if(manual) {
File mod = new File(gameDir + (extMod.type.equals("mod") ? "/mods" : "/resourcepacks"), extMod.slug + ".jar");
if(!mod.exists()) {
DownloadUtils.downloadFile(extMod.download_link, mod);
}
}
newExtMods.add(extMod);
}

extProjects = newExtMods.toArray(new ProjectInfo[0]);
}

private void downloadAllMods(List<ProjectInfo> newMods) throws IOException {
Expand Down

0 comments on commit a4632e4

Please sign in to comment.