22
33import fr .catcore .modremapperapi .utils .Constants ;
44import io .github .fabriccompatibiltylayers .modremappingapi .api .v1 .ModRemapper ;
5- import io .github .fabriccompatibiltylayers .modremappingapi .impl .DefaultModEntry ;
6- import io .github .fabriccompatibiltylayers .modremappingapi .impl .ModEntry ;
5+ import io .github .fabriccompatibiltylayers .modremappingapi .impl .DefaultModCandidate ;
6+ import io .github .fabriccompatibiltylayers .modremappingapi .impl .ModCandidate ;
77import io .github .fabriccompatibiltylayers .modremappingapi .impl .compatibility .V0ModRemapper ;
88import io .github .fabriccompatibiltylayers .modremappingapi .impl .discover .BaseModDiscoverer ;
99import io .github .fabriccompatibiltylayers .modremappingapi .impl .utils .CacheUtils ;
1010import io .github .fabriccompatibiltylayers .modremappingapi .impl .utils .FileUtils ;
1111import net .fabricmc .loader .api .FabricLoader ;
12- import net .fabricmc .loader .impl .launch .FabricLauncherBase ;
1312import org .jetbrains .annotations .NotNull ;
1413
1514import java .io .IOException ;
@@ -36,7 +35,7 @@ public Map<Path, Path> init(List<ModRemapper> modRemappers, boolean remapClassEd
3635 }
3736 }
3837
39- List <ModEntry > mods = new ArrayList <>();
38+ List <ModCandidate > mods = new ArrayList <>();
4039
4140 for (String jarFolder : modFolders ) {
4241 Path mcSubFolder = FabricLoader .getInstance ().getGameDir ().resolve (jarFolder );
@@ -77,30 +76,20 @@ public Map<Path, Path> init(List<ModRemapper> modRemappers, boolean remapClassEd
7776 modPaths = excludeClassEdits (modPaths , mainTempDir , context .getMappingsRegistry ());
7877 }
7978
80- for (Path path : modPaths .keySet ()) {
81- context .getMappingsRegistry ().addModMappings (path );
82- }
83-
84- context .getMappingsRegistry ().generateModMappings ();
85-
86- context .remapMods (modPaths );
87-
88- modPaths .values ().forEach (FabricLauncherBase .getLauncher ()::addToClassPath );
89-
9079 return modPaths ;
9180 }
9281
93- private void handleV0Excluded (List <ModEntry > mods ) throws IOException , URISyntaxException {
94- for (ModEntry modEntry : mods ) {
95- if (excluded .containsKey (modEntry .modId )) {
96- if (Files .isDirectory (modEntry .file )) {
97- for (String excluded : excluded .get (modEntry .modId )) {
98- if (Files .deleteIfExists (modEntry .file .resolve (excluded ))) {
99- Constants .MAIN_LOGGER .debug ("File deleted: " + modEntry .file .resolve (excluded ));
82+ private void handleV0Excluded (List <ModCandidate > mods ) throws IOException , URISyntaxException {
83+ for (ModCandidate modCandidate : mods ) {
84+ if (excluded .containsKey (modCandidate .modId )) {
85+ if (Files .isDirectory (modCandidate .file )) {
86+ for (String excluded : excluded .get (modCandidate .modId )) {
87+ if (Files .deleteIfExists (modCandidate .file .resolve (excluded ))) {
88+ Constants .MAIN_LOGGER .debug ("File deleted: " + modCandidate .file .resolve (excluded ));
10089 }
10190 }
10291 } else {
103- FileUtils .removeEntriesFromZip (modEntry .file , excluded .get (modEntry .modId ));
92+ FileUtils .removeEntriesFromZip (modCandidate .file , excluded .get (modCandidate .modId ));
10493 }
10594 }
10695 }
@@ -112,12 +101,22 @@ public boolean isValidFileName(String fileName) {
112101 }
113102
114103 @ Override
115- public boolean allowDirectories () {
104+ public boolean allowDirectoryMods () {
116105 return true ;
117106 }
118107
119108 @ Override
120- public Optional <ModEntry > discoverFolderMod (Path folder , Path destinationFolder ) throws IOException {
109+ public boolean searchRecursively () {
110+ return false ;
111+ }
112+
113+ @ Override
114+ public boolean isValidDirectoryName (String directoryName ) {
115+ return false ;
116+ }
117+
118+ @ Override
119+ public Optional <ModCandidate > discoverFolderMod (Path folder , Path destinationFolder ) throws IOException {
121120 String name = folder .getFileName ().toString ().replace (" " , "_" );
122121 Path destination = destinationFolder .resolve (name + ".zip" );
123122
@@ -137,7 +136,7 @@ public Optional<ModEntry> discoverFolderMod(Path folder, Path destinationFolder)
137136
138137 if (hasClasses [0 ]) {
139138 return Optional .of (
140- new DefaultModEntry (
139+ new DefaultModCandidate (
141140 name ,
142141 destination ,
143142 folder
@@ -149,7 +148,7 @@ public Optional<ModEntry> discoverFolderMod(Path folder, Path destinationFolder)
149148 }
150149
151150 @ Override
152- public Optional <ModEntry > discoverFileMod (Path file , Path destinationFolder ) throws IOException {
151+ public Optional <ModCandidate > discoverFileMod (Path file , Path destinationFolder ) throws IOException {
153152 String fileName = file .getFileName ().toString ().replace (" " , "_" );
154153 String modName = fileName .replace (".jar" , "" ).replace (".zip" , "" );
155154
@@ -167,7 +166,7 @@ public Optional<ModEntry> discoverFileMod(Path file, Path destinationFolder) thr
167166
168167 if (found ) {
169168 return Optional .of (
170- new DefaultModEntry (
169+ new DefaultModCandidate (
171170 modName ,
172171 destinationFolder .resolve (fileName ),
173172 file
0 commit comments