Skip to content

Commit

Permalink
Fix Resource Pack Downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
CADIndie committed Nov 3, 2024
1 parent cb40bdd commit 6db6575
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/main/java/pojlib/util/json/MinecraftInstances.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ private void removeModByType(List<ProjectInfo> oldMods, List<ProjectInfo> newMod
if(!remove) {
newExtProjects.add(extProject);
} else {
File mod = new File(gameDir + (extProject.type.equals("mod") ? "/mods" : "/resourcepacks"), extProject.slug + ".jar");
File mod = new File(
gameDir + (extProject.type.equals("mod") ? "/mods" : "/resourcepacks"),
extProject.slug + (extProject.type.equals("resourcepack") ? ".zip" : ".jar")
);
if(mod.exists()) {
mod.delete();
}
Expand Down Expand Up @@ -165,15 +168,21 @@ private void updateModByType(List<ProjectInfo> newMods) throws IOException {
continue;
}
manual = false;
File mod = new File(gameDir + (newMod.type.equals("mod") ? "/mods" : "/resourcepacks"), newMod.slug + ".jar");
File mod = new File(
gameDir + (newMod.type.equals("mod") ? "/mods" : "/resourcepacks"),
newMod.slug + (newMod.type.equals("resourcepack") ? ".zip" : ".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");
File mod = new File(
gameDir + (extMod.type.equals("mod") ? "/mods" : "/resourcepacks"),
extMod.slug + (extMod.type.equals("resourcepack") ? ".zip" : ".jar")
);
if(!mod.exists()) {
DownloadUtils.downloadFile(extMod.download_link, mod);
}
Expand All @@ -186,7 +195,10 @@ private void updateModByType(List<ProjectInfo> newMods) throws IOException {

private void downloadAllMods(List<ProjectInfo> newMods) throws IOException {
for(ProjectInfo newMod : newMods) {
File mod = new File(gameDir + (newMod.type.equals("mod") ? "/mods" : "/resourcepacks"), newMod.slug + ".jar");
File mod = new File(
gameDir + (newMod.type.equals("mod") ? "/mods" : "/resourcepacks"),
newMod.slug + (newMod.type.equals("resourcepack") ? ".zip" : ".jar")
);
DownloadUtils.downloadFile(newMod.download_link, mod);
}

Expand Down

0 comments on commit 6db6575

Please sign in to comment.