mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-04-02 05:27:43 -05:00
Fix crash introduced in previous zip related changes.
This commit is contained in:
@@ -72,15 +72,15 @@ public final class FileSystemUtil {
|
||||
}
|
||||
|
||||
public static Delegate getJarFileSystem(File file, boolean create) throws IOException {
|
||||
return getJarFileSystem(file.toURI(), create);
|
||||
return new Delegate(FileSystemReference.openJar(file.toPath(), create));
|
||||
}
|
||||
|
||||
public static Delegate getJarFileSystem(Path path, boolean create) throws IOException {
|
||||
return getJarFileSystem(path.toUri(), create);
|
||||
return new Delegate(FileSystemReference.openJar(path, create));
|
||||
}
|
||||
|
||||
public static Delegate getJarFileSystem(Path path) throws IOException {
|
||||
return getJarFileSystem(path, false);
|
||||
return new Delegate(FileSystemReference.openJar(path));
|
||||
}
|
||||
|
||||
public static Delegate getJarFileSystem(URI uri, boolean create) throws IOException {
|
||||
|
||||
@@ -47,7 +47,7 @@ public final class ModUtils {
|
||||
@Nullable
|
||||
public static JsonObject getFabricModJson(Path path) {
|
||||
try {
|
||||
return ZipUtils.unpackGson(path, "fabric.mod.json", JsonObject.class);
|
||||
return ZipUtils.unpackGsonNullable(path, "fabric.mod.json", JsonObject.class);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException("Failed to extract fabric.mod.json from " + path, e);
|
||||
}
|
||||
|
||||
@@ -112,6 +112,15 @@ public class ZipUtils {
|
||||
return LoomGradlePlugin.GSON.fromJson(new String(bytes, StandardCharsets.UTF_8), clazz);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T> T unpackGsonNullable(Path zip, String path, Class<T> clazz) throws IOException {
|
||||
try {
|
||||
return unpackGson(zip, path, clazz);
|
||||
} catch (NoSuchFileException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unpackJackson(Path zip, String path, Class<T> clazz) throws IOException {
|
||||
final byte[] bytes = unpack(zip, path);
|
||||
return LoomGradlePlugin.OBJECT_MAPPER.readValue(new String(bytes, StandardCharsets.UTF_8), clazz);
|
||||
|
||||
Reference in New Issue
Block a user