diff --git a/build.gradle b/build.gradle index 376dba2..f796166 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { id 'eclipse' id 'org.cadixdev.licenser' version '0.6.1' id 'org.gradlex.extra-java-module-info' version '1.4.2' - id 'net.minecraftforge.gradleutils' version '2.+' + id 'net.minecraftforge.gradleutils' version '[2.3.0,2.4)' } group = 'net.minecraftforge' @@ -34,7 +34,7 @@ extraJavaModuleInfo { } changelog { - fromTag '0.9' + from '0.9' } tasks.named('jar', Jar).configure { diff --git a/sm-jmh/build.gradle b/sm-jmh/build.gradle index d2addf9..1dc911c 100644 --- a/sm-jmh/build.gradle +++ b/sm-jmh/build.gradle @@ -2,7 +2,7 @@ plugins { id 'eclipse' id 'java-library' id 'org.gradlex.extra-java-module-info' version '1.4.2' - id 'net.minecraftforge.gradleutils' version '2.+' + id 'net.minecraftforge.gradleutils' version '[2.3.0,2.4)' id 'com.diffplug.eclipse.apt' version '3.43.0' } diff --git a/sm-test/build.gradle b/sm-test/build.gradle index 5f6c257..8416157 100644 --- a/sm-test/build.gradle +++ b/sm-test/build.gradle @@ -3,7 +3,7 @@ plugins { id 'eclipse' id 'java-library' id 'org.gradlex.extra-java-module-info' version '1.4.2' - id 'net.minecraftforge.gradleutils' version '2.+' + id 'net.minecraftforge.gradleutils' version '[2.3.0,2.4)' } repositories { diff --git a/src/main/java/cpw/mods/jarhandling/impl/Jar.java b/src/main/java/cpw/mods/jarhandling/impl/Jar.java index 9d6e88e..af72711 100644 --- a/src/main/java/cpw/mods/jarhandling/impl/Jar.java +++ b/src/main/java/cpw/mods/jarhandling/impl/Jar.java @@ -17,7 +17,6 @@ import java.net.URISyntaxException; import java.nio.file.FileSystem; import java.nio.file.FileSystemAlreadyExistsException; -import java.nio.file.FileSystemNotFoundException; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -185,15 +184,25 @@ private Path newFileSystem(BiPredicate filter, Path[] paths) { if (filter == null && paths.length == 1) { if (Files.isDirectory(paths[0])) return paths[0]; - // We have to manually open the jar files up via a URI instead of a Path - // because the ZipFileSystem implementation only caches the FileSystems - // when accessed that way. But we can only open it once or else it throws - // a FileSystemAlreadyExistsException. So, exceptions as codeflow, yay! - var uri = new URI("jar:" + paths[0].toUri()); - try { - fs = FileSystems.newFileSystem(uri, Map.of(), null); - } catch (FileSystemAlreadyExistsException e) { - fs = FileSystems.getFileSystem(uri); + var uri = paths[0].toUri(); + if ("file".equals(uri.getScheme())) { + // We have to manually open the jar files up via a URI instead of a Path + // because the ZipFileSystem implementation only caches the FileSystems + // when accessed that way. But we can only open it once or else it throws + // a FileSystemAlreadyExistsException. So, exceptions as codeflow, yay! + uri = new URI("jar:" + uri); + try { + fs = FileSystems.newFileSystem(uri, Map.of(), null); + } catch (FileSystemAlreadyExistsException e) { + fs = FileSystems.getFileSystem(uri); + } + } else { + // JarInJar is fucking stupid and breaks horribly if it knows about files directly. + // So because I don't want to go into the rabbit hole that is digging into that + // Any non-standard file system will be wrapped in a Union File System + // This still gets the performance benefit of having 90% of everything bypass the UFS + // TODO: [SM] Remove JarInJar file system in favor of a simpler dependency management system. + fs = UFSP.newFileSystem(paths[0], Map.of("filter", (BiPredicate)(a, b) -> true)); } } else { var map = new HashMap(); diff --git a/src/main/java/cpw/mods/niofs/union/UnionFileSystemProvider.java b/src/main/java/cpw/mods/niofs/union/UnionFileSystemProvider.java index 1aea979..c1057eb 100644 --- a/src/main/java/cpw/mods/niofs/union/UnionFileSystemProvider.java +++ b/src/main/java/cpw/mods/niofs/union/UnionFileSystemProvider.java @@ -124,9 +124,22 @@ private UnionFileSystem newFileSystemInternal(final String key, final BiPredicat } private synchronized String makeKey(Path path) { - var key= (path instanceof UnionPath p) ? p.getFileSystem().getKey() : - path.toAbsolutePath().normalize().toUri().getPath(); - return key.replace('!', '_') + "#" + index++; + String key; + if (path instanceof UnionPath p) + key = p.getFileSystem().getKey(); + else { + var uri = path.toAbsolutePath().normalize().toUri(); + key = uri.getPath(); + if (key == null) // Fuck it this doesn't actually mean anything is just nice for debugging + key = uri.toString(); + } + + key = key.replace('!', '_') + "#" + index++; + + if (key.charAt(0) != '/') + key = '/' + key; // URI's require anything that uses schemas to use absolute paths. So make sure our key is absolute. + + return key; } @Override