-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: child folder mod locator #294
base: experimental/foundation
Are you sure you want to change the base?
feat: child folder mod locator #294
Conversation
- will not load child folder named `optional` or `disabled`
@@ -492,6 +495,18 @@ else if (!list.contains(file)) | |||
return list; | |||
} | |||
|
|||
private static void scanningChildFolder(File directory, List<File> list) { | |||
if (directory.isDirectory() && !(directory.getName().toLowerCase().contains("optional") || directory.getName().toLowerCase().contains("disabled"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contains
?, or equals
"optional".equalsIgnoreCase(directory.getName())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason to be strict about folder names
@@ -492,6 +495,18 @@ else if (!list.contains(file)) | |||
return list; | |||
} | |||
|
|||
private static void scanningChildFolder(File directory, List<File> list) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scan the sub sub dir?
enable path?
sub sub
Supporting paths is useless, mods that need to do so will inject it themselves
public static List<File> scanningModFiles(Path rootDir) {
try (Stream<Path> stream = Files.walk(rootDir)) {
return stream
.filter(path -> {
Path parent = path.getParent();
return parent != null && !("disabled".equalsIgnoreCase(parent.getFileName().toString()) || "optional".equalsIgnoreCase(parent.getFileName().toString()));
})
.filter(Files::isRegularFile)
.map(Path::toFile)
.filter(File::isFile)
.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException("Unable to scan mod folder", e)
}
}
@@ -469,12 +469,15 @@ else if (!list.contains(file)) | |||
|
|||
for (String dir : new String[]{"mods", "mods" + File.separatorChar + ForgeVersion.mcVersion}) | |||
{ | |||
List<File> location = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return it instead of using it like this?
It is understandable that "disabled" is not loaded, but why is "optional" also considered. |
i will rewrite them all when i am home |
Maybe make the names configurable |
On a second thought, maybe make it configurable regex |
black/white list for scannable folder maybe |
- removed sub-sub folder compatible - add white/black list for special folder
FMLLog.log.info("Searching {} for mods", base.getAbsolutePath()); | ||
for (File f : base.listFiles(MOD_FILENAME_FILTER)) | ||
for (File f : location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could just inline the var
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth considering whether an API for file locator will be added in future, like IModFileCandidateLocator
in FancyML
return stream | ||
.filter(path -> { | ||
Path parent = path.getParent(); | ||
return parent == null || (Arrays.stream(ForgeEarlyConfig.SPECIAL_MOD_FOLDER).toList().contains(parent.getFileName().toString()) && ForgeEarlyConfig.IS_WHITELIST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the case be considered?
@@ -18,4 +18,9 @@ public class ForgeEarlyConfig { | |||
public static String X11_CLASS_NAME = "minecraft"; | |||
public static String COCOA_FRAME_NAME = "minecraft"; | |||
public static String CONFIG_ANY_TIME_VERSION = "3.0"; | |||
|
|||
public static String[] SPECIAL_MOD_FOLDER = new String[]{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would sub category be considered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#294 (comment)
hope I am not mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#294 (comment) hope I am not mistaken.
I means config category.
ForgeEarlyConfig.modloading.disabledList
oh, my.error return parent!= null && !("disabled".equalsIgnoreCase(parent.getFileName().toString()) || "optional".equalsIgnoreCase(parent.getFileName().toString())); |
Should write a proposal for this, I guess |
- removed whitelist - inline var
may crash? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, let’s resolve the conflict.
will not load child folder named

optional
ordisabled