Skip to content

Commit aa1895a

Browse files
authored
feat: option to ignore all mods for auto-curseforge (#675)
1 parent 289f0ee commit aa1895a

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

src/main/java/me/itzg/helpers/curseforge/CurseForgeInstaller.java

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.nio.file.Path;
1818
import java.nio.file.Paths;
1919
import java.time.Duration;
20+
import java.util.ArrayList;
2021
import java.util.Arrays;
2122
import java.util.Collection;
2223
import java.util.Collections;
@@ -145,6 +146,9 @@ public class CurseForgeInstaller {
145146
@Getter @Setter
146147
private String customModLoaderVersion;
147148

149+
@Getter @Setter
150+
private boolean excludeAllMods;
151+
148152
/**
149153
*/
150154
public void installFromModpackZip(Path modpackZip, String slug) {
@@ -546,20 +550,11 @@ private void trimLevelsContent(CurseForgeManifest manifest) {
546550
});
547551
}
548552

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

556-
final ModLoader modLoader = modpackManifest.getMinecraft().getModLoaders().stream()
557-
.filter(ModLoader::isPrimary)
558-
.findFirst()
559-
.orElseThrow(() -> new GenericException("Unable to find primary mod loader in modpack"));
560-
561-
final OutputSubdirResolver outputSubdirResolver = new OutputSubdirResolver(outputDir, context.categoryInfo);
562-
563558
final ExcludeIncludeIds excludeIncludeIds = resolveExcludeIncludes(context);
564559
log.debug("Using {}", excludeIncludeIds);
565560

@@ -602,6 +597,25 @@ private ModPackResults processModpack(InstallContext context,
602597
.collectList()
603598
.block();
604599

600+
return modFiles;
601+
}
602+
603+
private ModPackResults processModpack(InstallContext context,
604+
MinecraftModpackManifest modpackManifest, OverridesApplier overridesApplier
605+
) throws IOException {
606+
if (modpackManifest.getManifestType() != ManifestType.minecraftModpack) {
607+
throw new InvalidParameterException("The zip file provided does not seem to be a Minecraft modpack");
608+
}
609+
610+
final ModLoader modLoader = modpackManifest.getMinecraft().getModLoaders().stream()
611+
.filter(ModLoader::isPrimary)
612+
.findFirst()
613+
.orElseThrow(() -> new GenericException("Unable to find primary mod loader in modpack"));
614+
615+
final OutputSubdirResolver outputSubdirResolver = new OutputSubdirResolver(outputDir, context.categoryInfo);
616+
617+
final List<PathWithInfo> modFiles = getModFiles(context, modpackManifest, outputSubdirResolver);
618+
605619
final Result overridesResult = overridesApplier.apply();
606620

607621
prepareModLoader(modLoader.getId(), modpackManifest.getMinecraft().getVersion());

src/main/java/me/itzg/helpers/curseforge/InstallCurseForgeCommand.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ public void setForceIncludeMods(Set<String> forceIncludeMods) {
128128
}
129129
Set<String> forceIncludeMods;
130130
}
131+
132+
@Option(
133+
names = "--exclude-all-mods",
134+
description = "Exclude all mods regardless of manifest contents"
135+
)
136+
boolean excludeAllMods;
131137
}
132138

133139
@Option(names = "--filename-matcher", paramLabel = "STR",
@@ -239,7 +245,8 @@ public Integer call() throws Exception {
239245
.setMaxConcurrentDownloads(maxConcurrentDownloads)
240246
.setFileDownloadRetries(fileDownloadRetries)
241247
.setFileDownloadRetryMinDelay(fileDownloadRetryMinDelay)
242-
.setCustomModLoaderVersion(modLoaderVersion);
248+
.setCustomModLoaderVersion(modLoaderVersion)
249+
.setExcludeAllMods(excludeIncludeArgs.excludeAllMods);
243250

244251
if (apiBaseUrl != null) {
245252
installer.setApiBaseUrl(apiBaseUrl);

0 commit comments

Comments
 (0)