Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -145,6 +146,9 @@ public class CurseForgeInstaller {
@Getter @Setter
private String customModLoaderVersion;

@Getter @Setter
private boolean excludeAllMods;

/**
*/
public void installFromModpackZip(Path modpackZip, String slug) {
Expand Down Expand Up @@ -546,20 +550,11 @@ private void trimLevelsContent(CurseForgeManifest manifest) {
});
}

private ModPackResults processModpack(InstallContext context,
MinecraftModpackManifest modpackManifest, OverridesApplier overridesApplier
) throws IOException {
if (modpackManifest.getManifestType() != ManifestType.minecraftModpack) {
throw new InvalidParameterException("The zip file provided does not seem to be a Minecraft modpack");
private List<PathWithInfo> getModFiles(InstallContext context, MinecraftModpackManifest modpackManifest, OutputSubdirResolver outputSubdirResolver) {
if (excludeAllMods) {
return new ArrayList<>();
}

final ModLoader modLoader = modpackManifest.getMinecraft().getModLoaders().stream()
.filter(ModLoader::isPrimary)
.findFirst()
.orElseThrow(() -> new GenericException("Unable to find primary mod loader in modpack"));

final OutputSubdirResolver outputSubdirResolver = new OutputSubdirResolver(outputDir, context.categoryInfo);

final ExcludeIncludeIds excludeIncludeIds = resolveExcludeIncludes(context);
log.debug("Using {}", excludeIncludeIds);

Expand Down Expand Up @@ -602,6 +597,25 @@ private ModPackResults processModpack(InstallContext context,
.collectList()
.block();

return modFiles;
}

private ModPackResults processModpack(InstallContext context,
MinecraftModpackManifest modpackManifest, OverridesApplier overridesApplier
) throws IOException {
if (modpackManifest.getManifestType() != ManifestType.minecraftModpack) {
throw new InvalidParameterException("The zip file provided does not seem to be a Minecraft modpack");
}

final ModLoader modLoader = modpackManifest.getMinecraft().getModLoaders().stream()
.filter(ModLoader::isPrimary)
.findFirst()
.orElseThrow(() -> new GenericException("Unable to find primary mod loader in modpack"));

final OutputSubdirResolver outputSubdirResolver = new OutputSubdirResolver(outputDir, context.categoryInfo);

final List<PathWithInfo> modFiles = getModFiles(context, modpackManifest, outputSubdirResolver);

final Result overridesResult = overridesApplier.apply();

prepareModLoader(modLoader.getId(), modpackManifest.getMinecraft().getVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ public void setForceIncludeMods(Set<String> forceIncludeMods) {
}
Set<String> forceIncludeMods;
}

@Option(
names = "--exclude-all-mods",
description = "Exclude all mods regardless of manifest contents"
)
boolean excludeAllMods;
}

@Option(names = "--filename-matcher", paramLabel = "STR",
Expand Down Expand Up @@ -239,7 +245,8 @@ public Integer call() throws Exception {
.setMaxConcurrentDownloads(maxConcurrentDownloads)
.setFileDownloadRetries(fileDownloadRetries)
.setFileDownloadRetryMinDelay(fileDownloadRetryMinDelay)
.setCustomModLoaderVersion(modLoaderVersion);
.setCustomModLoaderVersion(modLoaderVersion)
.setExcludeAllMods(excludeIncludeArgs.excludeAllMods);

if (apiBaseUrl != null) {
installer.setApiBaseUrl(apiBaseUrl);
Expand Down