@@ -53,29 +53,29 @@ public static MappingSet readMappings(Path mappingsFile) {
5353 MappingSet mappings = MappingSet .create ();
5454 MappingType type = getMappingType (mappingsFile );
5555 FileSystem fileSystem = null ; // If a filesystem is created in a jar, we need to close it manually
56- AtomicReference < Path > path = new AtomicReference <>( mappingsFile ) ;
56+ Path [] path = new Path []{ mappingsFile } ;
5757
58- switch (type ) {
59- case ZIP :
60- case JAR : {
61- // We need to find the mappings. Find the first valid mapping file we can.
62- try {
63- fileSystem = FileSystems .newFileSystem (mappingsFile , (ClassLoader ) null );
64- fileSystem .getRootDirectories ().forEach (p -> {
65- String name = p .toString ();
66-
67- // A bit hacky, but yarn bundle more than mappings in their jars
68- if (name .contains ("mappings" ) || name .contains ("parchment" )) {
69- path .set (p );
70- }
71- });
72- } catch (IOException ex ) {
73- throw new GradleException ("Failed to read mappings from " + mappingsFile , ex );
74- }
58+ if (type == MappingType .JAR || type == MappingType .ZIP ) {
59+ // We need to find the mappings. Find the first valid mapping file we can.
60+ try {
61+ fileSystem = FileSystems .newFileSystem (mappingsFile , (ClassLoader ) null );
62+ fileSystem .getRootDirectories ().forEach (p -> {
63+ String name = p .toString ();
64+
65+ // A bit hacky, but yarn bundle more than mappings in their jars
66+ if (name .contains ("mappings" ) || name .contains ("parchment" )) {
67+ path [0 ] = p ;
68+ }
69+ });
70+ } catch (IOException ex ) {
71+ throw new GradleException ("Failed to read mappings from " + mappingsFile , ex );
7572 }
73+ }
7674
75+ type = getMappingType (path [0 ]);
76+ switch (type ) {
7777 case PROGUARD : {
78- try (BufferedReader reader = Files .newBufferedReader (path . get () , StandardCharsets .UTF_8 )) {
78+ try (BufferedReader reader = Files .newBufferedReader (path [ 0 ] , StandardCharsets .UTF_8 )) {
7979 final ProGuardReader proguard = new ProGuardReader (reader );
8080 proguard .read (mappings );
8181 mappings = mappings .reverse (); // Flip from named -> obf to named -> obf
@@ -87,7 +87,7 @@ public static MappingSet readMappings(Path mappingsFile) {
8787
8888 case TINY : {
8989 try {
90- mappings = TinyMappingFormat .DETECT .read (path . get () , "official" , "named" );
90+ mappings = TinyMappingFormat .DETECT .read (path [ 0 ] , "official" , "named" );
9191 } catch (IOException ex ) {
9292 throw new GradleException ("Failed to read mappings from " + mappingsFile , ex );
9393 }
@@ -96,7 +96,7 @@ public static MappingSet readMappings(Path mappingsFile) {
9696
9797 case SRG : {
9898 final MappingSet finalMappings = mappings ;
99- read (path . get () , (reader ) -> {
99+ read (path [ 0 ] , (reader ) -> {
100100 final SrgReader srg = new SrgReader (reader );
101101 srg .read (finalMappings );
102102 });
@@ -105,7 +105,7 @@ public static MappingSet readMappings(Path mappingsFile) {
105105
106106 case TSRG : {
107107 final MappingSet finalMappings = mappings ;
108- read (path . get () , (reader ) -> {
108+ read (path [ 0 ] , (reader ) -> {
109109 final TSrgReader tsrg = new TSrgReader (reader );
110110 tsrg .read (finalMappings );
111111 });
@@ -115,7 +115,7 @@ public static MappingSet readMappings(Path mappingsFile) {
115115 case PARCHMENT : {
116116 final MappingSet finalMappings = mappings ;
117117
118- read (path . get () , (reader ) -> {
118+ read (path [ 0 ] , (reader ) -> {
119119 //TODO: complete. This is a bit trickier than the others.
120120 // We need to first get the mapping set for mojmap, then apply Parchment on top.
121121 // But how do we know which mojmap to use? probably could just guess by using the version.
0 commit comments