@@ -455,44 +455,45 @@ private boolean applyModpack() throws Exception {
455455 // Copy files to running directory
456456 boolean needsRestart1 = ModpackUtils .correctFilesLocations (modpackDir , modpackContent , filesNotToCopy );
457457
458- // Check if the conflicting mods still exits, they might have been deleted by methods above
459- conflictingNestedMods = conflictingNestedMods .stream ()
460- .filter (conflictingMod -> {
461- Path standardModsDir = MODS_DIR .resolve (conflictingMod .modPath ().getFileName ());
462- return Files .exists (standardModsDir );
463- })
464- .toList ();
465-
466- if (!conflictingNestedMods .isEmpty ()) {
467- LOGGER .warn ("Found conflicting nested mods: {}" , conflictingNestedMods );
468- }
469-
470- final List <Path > modpackMods ;
471- final Collection <FileInspection .Mod > modpackModList ;
472- final List <Path > standardMods ;
473- final Collection <FileInspection .Mod > standardModList ;
474-
458+ Set <Path > modpackMods = new HashSet <>();
459+ Collection <FileInspection .Mod > modpackModList = new ArrayList <>();
475460 Path modpackModsDir = modpackDir .resolve ("mods" );
476461 if (Files .exists (modpackModsDir )) {
477- try (Stream <Path > modpackModsStream = Files .list (modpackModsDir )) {
478- modpackMods = modpackModsStream .toList ();
479- modpackModList = modpackMods .stream ().map (FileInspection ::getMod ).filter (Objects ::nonNull ).toList ();
462+ try (Stream <Path > stream = Files .list (modpackModsDir )) {
463+ stream .forEach (path -> {
464+ modpackMods .add (path );
465+ FileInspection .Mod mod = FileInspection .getMod (path );
466+ if (mod != null ) {
467+ modpackModList .add (mod );
468+ }
469+ });
480470 }
481- } else {
482- modpackModList = List .of ();
483471 }
484472
485- if (Files .exists (MODS_DIR )) {
486- try (Stream <Path > standardModsStream = Files .list (MODS_DIR )) {
487- standardMods = standardModsStream .toList ();
488- standardModList = new ArrayList <>(standardMods .stream ().map (FileInspection ::getMod ).filter (Objects ::nonNull ).toList ());
473+ Collection <FileInspection .Mod > standardModList = new ArrayList <>();
474+ Path standardModsDir = MODS_DIR ;
475+ if (Files .exists (standardModsDir )) {
476+ try (Stream <Path > stream = Files .list (standardModsDir )) {
477+ stream .forEach (path -> {
478+ FileInspection .Mod mod = FileInspection .getMod (path );
479+ if (mod != null ) {
480+ standardModList .add (mod );
481+ }
482+ });
489483 }
490- } else {
491- standardModList = new ArrayList <>();
484+ }
485+
486+ // Check if the conflicting mods still exits, they might have been deleted by methods above
487+ conflictingNestedMods = conflictingNestedMods .stream ()
488+ .filter (conflictingMod -> modpackMods .contains (conflictingMod .modPath ()))
489+ .toList ();
490+
491+ if (!conflictingNestedMods .isEmpty ()) {
492+ LOGGER .warn ("Found conflicting nested mods: {}" , conflictingNestedMods );
492493 }
493494
494495 boolean needsRestart2 = ModpackUtils .fixNestedMods (conflictingNestedMods , standardModList );
495- Set <String > ignoredFiles = ModpackUtils .getIgnoredWithNested (conflictingNestedMods , filesNotToCopy );
496+ Set <String > ignoredFiles = ModpackUtils .getWorkaroundsWithNested (conflictingNestedMods , workaroundMods );
496497
497498 // Remove duplicate mods
498499 boolean needsRestart3 = ModpackUtils .removeDupeMods (modpackDir , standardModList , modpackModList , ignoredFiles , workaroundMods );
0 commit comments