Skip to content

Commit

Permalink
cf: provide option to force reinstall modpack's modloader (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg authored Feb 5, 2024
1 parent d522439 commit 76a30ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public class CurseForgeInstaller {
@Getter @Setter
private List<String> overridesExclusions;

@Getter @Setter
private boolean forceReinstallModloader;

/**
* @throws MissingModsException if any mods need to be manually downloaded
*/
Expand Down Expand Up @@ -879,7 +882,8 @@ private void prepareModLoader(String id, String minecraftVersion) {

private void prepareFabric(String minecraftVersion, String loaderVersion) {
final FabricLauncherInstaller installer = new FabricLauncherInstaller(outputDir)
.setResultsFile(resultsFile);
.setResultsFile(resultsFile)
.setForceReinstall(forceReinstallModloader);
installer.installUsingVersions(minecraftVersion, loaderVersion, null);
}

Expand All @@ -889,7 +893,7 @@ private void prepareForge(SharedFetch sharedFetch, String minecraftVersion, Stri
minecraftVersion, forgeVersion
)
)
.install(outputDir, resultsFile, false, "Forge");
.install(outputDir, resultsFile, forceReinstallModloader, "Forge");
}

private MinecraftModpackManifest extractModpackManifest(Path modpackZip) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ static class Listed {
@Option(names = "--force-synchronize")
boolean forceSynchronize;

@Option(names = "--force-reinstall-modloader")
boolean forceReinstallModloader;

@Option(names = "--set-level-from",
description = "When WORLD_FILE, a world file included the modpack will be unzipped into a folder under 'saves' and referenced as 'LEVEL' in the results file."
+ "\nWhen OVERRIDES and the overrides contains a world save directory (contains level.dat), then that directory will be referenced as 'LEVEL' in the results file."
Expand Down Expand Up @@ -190,6 +193,7 @@ public Integer call() throws Exception {
final CurseForgeInstaller installer = new CurseForgeInstaller(outputDirectory, resultsFile)
.setExcludeIncludes(excludeIncludes)
.setForceSynchronize(forceSynchronize)
.setForceReinstallModloader(forceReinstallModloader)
.setLevelFrom(levelFrom)
.setOverridesSkipExisting(overridesSkipExisting)
.setOverridesExclusions(overridesExclusions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ public class FabricLauncherInstaller {
@Setter
private Path resultsFile;

@Getter
@Setter
@Getter @Setter
private String fabricMetaBaseUrl = "https://meta.fabricmc.net";

@Getter @Setter
private boolean forceReinstall;

public void installUsingVersions(
@NonNull String minecraftVersion,
@Nullable String loaderVersion,
Expand Down Expand Up @@ -86,6 +88,7 @@ private Mono<FabricManifest> downloadResolvedLauncher(FabricMetaClient fabricMet

final boolean needsInstall =
prevManifest == null
|| forceReinstall
|| prevManifest.getOrigin() == null
|| !prevManifest.getOrigin().equals(expectedVersions)
|| !Manifests.allFilesPresent(outputDir, prevManifest);
Expand Down

0 comments on commit 76a30ea

Please sign in to comment.