@@ -29,30 +29,30 @@ public void download(final CommonDependency dependency) {
2929 return ;
3030 }
3131
32- Path zipFilePath = mappingsDir .resolve (dependency .name ().toLowerCase () + "/download.zip " );
33- Files .createDirectories (zipFilePath .getParent ());
32+ Path resolvedMappingPath = mappingsDir .resolve (dependency .name ().toLowerCase () + "/download.mappings " );
33+ Files .createDirectories (resolvedMappingPath .getParent ());
3434
3535 // Download the zip file
3636 Skidfuscator .LOGGER .style (String .format ("Downloading dependency %s from %s\n " , dependency .name (), url ));
3737 try (BufferedInputStream in = new BufferedInputStream (new URL (url ).openStream ());
38- FileOutputStream fileOutputStream = new FileOutputStream (zipFilePath .toFile ())) {
38+ FileOutputStream fileOutputStream = new FileOutputStream (resolvedMappingPath .toFile ())) {
3939 byte [] dataBuffer = new byte [1024 ];
4040 int bytesRead ;
4141 while ((bytesRead = in .read (dataBuffer , 0 , 1024 )) != -1 ) {
4242 fileOutputStream .write (dataBuffer , 0 , bytesRead );
4343 }
4444 }
4545
46- if (!Files .exists (zipFilePath )) {
47- throw new IOException ("Failed to download the file: " + zipFilePath );
46+ if (!Files .exists (resolvedMappingPath )) {
47+ throw new IOException ("Failed to download the file: " + resolvedMappingPath );
4848 }
4949
50- Skidfuscator .LOGGER .style (String .format ("Downloaded dependency %s to %s\n " , dependency .name (), zipFilePath ));
50+ Skidfuscator .LOGGER .style (String .format ("Downloaded dependency %s to %s\n " , dependency .name (), resolvedMappingPath ));
5151
5252 if (url .endsWith (".jar" )) {
5353 throw new IllegalArgumentException ("Invalid dependency type" );
5454 } else if (url .endsWith (".zip" )) {
55- try (ZipInputStream zipInputStream = new ZipInputStream (Files .newInputStream (zipFilePath ))) {
55+ try (ZipInputStream zipInputStream = new ZipInputStream (Files .newInputStream (resolvedMappingPath ))) {
5656 ZipEntry entry ;
5757 while ((entry = zipInputStream .getNextEntry ()) != null ) {
5858 Path filePath = mappingsDir .resolve (entry .getName ());
@@ -71,10 +71,15 @@ public void download(final CommonDependency dependency) {
7171 zipInputStream .closeEntry ();
7272 }
7373 }
74- Files .delete (zipFilePath );
7574 Skidfuscator .LOGGER .style (String .format ("Extracted dependency %s to %s\n " , dependency .name (), mappingsDir .toFile ().getAbsolutePath ()));
76- } else {
75+ } else if (url .endsWith (".json" )) {
76+ // Copy the file to the mappings directory
77+ Files .copy (resolvedMappingPath , mappingsDir .resolve (dependency .name ().toLowerCase () + ".json" ));
78+ Skidfuscator .LOGGER .style (String .format ("Extracted JSON particular dependency %s to %s\n " , dependency .name (), mappingsDir .toFile ().getAbsolutePath ()));
79+ }
80+ else {
7781 Skidfuscator .LOGGER .style (String .format ("Unsupported file type for %s\n " , url ));
7882 }
83+ Files .delete (resolvedMappingPath );
7984 }
8085}
0 commit comments