diff --git a/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java b/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java index 72fd5e89e..b0a99c6c3 100644 --- a/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java +++ b/src/main/java/net/fabricmc/loader/impl/discovery/DirectoryModCandidateFinder.java @@ -26,6 +26,7 @@ import java.util.EnumSet; import net.fabricmc.loader.impl.util.LoaderUtil; +import net.fabricmc.loader.impl.util.SystemProperties; import net.fabricmc.loader.impl.util.log.Log; import net.fabricmc.loader.impl.util.log.LogCategory; @@ -54,10 +55,12 @@ public void findCandidates(ModCandidateConsumer out) { } try { - Files.walkFileTree(this.path, EnumSet.of(FileVisitOption.FOLLOW_LINKS), 1, new SimpleFileVisitor() { + Files.walkFileTree(this.path, EnumSet.of(FileVisitOption.FOLLOW_LINKS), System.getProperty(SystemProperties.LOAD_MODS_RECURSIVELY) != null ? Integer.MAX_VALUE : 1, new SimpleFileVisitor() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (isValidFile(file)) { + if (file.getParent() != null && file.getParent().toString().contains("disabled")) { + return FileVisitResult.SKIP_SUBTREE; + } else if (isValidFile(file)) { out.accept(file, requiresRemap); } diff --git a/src/main/java/net/fabricmc/loader/impl/util/SystemProperties.java b/src/main/java/net/fabricmc/loader/impl/util/SystemProperties.java index 658767bd5..4ff266a72 100644 --- a/src/main/java/net/fabricmc/loader/impl/util/SystemProperties.java +++ b/src/main/java/net/fabricmc/loader/impl/util/SystemProperties.java @@ -34,6 +34,8 @@ public final class SystemProperties { public static final String LOG_LEVEL = "fabric.log.level"; // a path to a directory to replace the default mod search directory public static final String MODS_FOLDER = "fabric.modsFolder"; + // whether to load mods recursively from the mods folder. Paths that contain "disabled" are ignored + public static final String LOAD_MODS_RECURSIVELY = "fabric.loadModsRecursively"; // additional mods to load (path separator separated paths, @ prefix for meta-file with each line referencing an actual file) public static final String ADD_MODS = "fabric.addMods"; // a comma-separated list of mod ids to disable, even if they're discovered. mostly useful for unit testing.