From c675729996b065670256ddc188870dfdaab25650 Mon Sep 17 00:00:00 2001 From: Natty <31473117+493msi@users.noreply.github.com> Date: Wed, 6 Apr 2022 23:55:49 +0200 Subject: [PATCH] Fixed several resource filesystem bugs --- UPDATE_NOTES.md | 3 +++ buildSrc/src/main/kotlin/org/plutoengine/Versions.kt | 2 +- .../resource/filesystem/ResourceFileSystemProvider.java | 9 ++++++++- .../plutoengine/resource/filesystem/ResourceManager.java | 5 ++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/UPDATE_NOTES.md b/UPDATE_NOTES.md index 77a5406..90df53b 100755 --- a/UPDATE_NOTES.md +++ b/UPDATE_NOTES.md @@ -1,3 +1,6 @@ +## 22.0.0.0-alpha.7 +* `[PlutoRuntime]` Fixed several resource filesystem bugs + ## 22.0.0.0-alpha.6 * `[PlutoSpritesheet]` Added a constructor to `PartialTextureSprite` that initializes the spritesheet to `null` diff --git a/buildSrc/src/main/kotlin/org/plutoengine/Versions.kt b/buildSrc/src/main/kotlin/org/plutoengine/Versions.kt index 77737dc..655f5ab 100755 --- a/buildSrc/src/main/kotlin/org/plutoengine/Versions.kt +++ b/buildSrc/src/main/kotlin/org/plutoengine/Versions.kt @@ -22,7 +22,7 @@ object Versions { const val isPrerelease = true const val prereleaseName = "alpha" - const val prerealeaseUpdate = 6 + const val prerealeaseUpdate = 7 val versionFull = if (isPrerelease) diff --git a/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceFileSystemProvider.java b/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceFileSystemProvider.java index ebbd1e1..2ff9c6c 100755 --- a/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceFileSystemProvider.java +++ b/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceFileSystemProvider.java @@ -156,7 +156,14 @@ public class ResourceFileSystemProvider extends FileSystemProvider @Override public AsynchronousFileChannel newAsynchronousFileChannel(Path path, Set options, ExecutorService executor, FileAttribute... attrs) throws IOException { - return super.newAsynchronousFileChannel(path, options, executor, attrs); + if (!(path instanceof ResourcePath rp)) + throw new IllegalArgumentException("Expected a path of type %s!".formatted(ResourcePath.class)); + + var backingPath = rp.getBackingPath(); + var backingFileSystem = backingPath.getFileSystem(); + var backingProvider = backingFileSystem.provider(); + + return backingProvider.newAsynchronousFileChannel(backingPath, options, executor, attrs); } @Override diff --git a/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceManager.java b/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceManager.java index 33a8079..d2dafea 100755 --- a/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceManager.java +++ b/engine-core/plutoruntime/src/main/java/org/plutoengine/resource/filesystem/ResourceManager.java @@ -6,6 +6,7 @@ import org.plutoengine.mod.Mod; import javax.annotation.concurrent.ThreadSafe; import java.io.Closeable; import java.io.IOException; +import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.ProviderNotFoundException; import java.nio.file.spi.FileSystemProvider; @@ -30,9 +31,7 @@ public class ResourceManager implements Closeable { try { - var loader = ServiceLoader.load(FileSystemProvider.class, ResourceFileSystemProvider.class.getClassLoader()); - - for (FileSystemProvider provider : loader) + for (FileSystemProvider provider : FileSystemProvider.installedProviders()) { if (provider.getScheme().equals(URI_SCHEME)) {