Skip to content

Commit

Permalink
Fix createFromZipOptional/Nullable crashing when the file doesn't exi…
Browse files Browse the repository at this point in the history
…st on Quilt Loom
  • Loading branch information
TheGlitch76 committed Apr 29, 2024
1 parent ccd0ac6 commit 5fa3580
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions patches/0003-Support-QMJ.patch
Original file line number Diff line number Diff line change
Expand Up @@ -513,28 +513,29 @@ index aaa5316951acae21a74c5725ab77b4e95703f6b7..d1faad3542974895bee6147a1c2cbe2e
import java.util.Objects;

diff --git a/src/main/java/net/fabricmc/loom/util/fmj/FabricModJsonHelpers.java b/src/main/java/net/fabricmc/loom/configuration/metadata/ModMetadataHelper.java
similarity index 60%
similarity index 57%
rename from src/main/java/net/fabricmc/loom/util/fmj/FabricModJsonHelpers.java
rename to src/main/java/net/fabricmc/loom/configuration/metadata/ModMetadataHelper.java
index 923c7a30d4d9785dbf26ef3f59f044197a53abe1..490240ac688d7fddba464b70005d7c236265c9b2 100644
index 923c7a30d4d9785dbf26ef3f59f044197a53abe1..c4f77460515eddffab5924ee5351ed3b8f3c6ff0 100644
--- a/src/main/java/net/fabricmc/loom/util/fmj/FabricModJsonHelpers.java
+++ b/src/main/java/net/fabricmc/loom/configuration/metadata/ModMetadataHelper.java
@@ -22,10 +22,13 @@
@@ -22,10 +22,14 @@
* SOFTWARE.
*/

-package net.fabricmc.loom.util.fmj;
+package net.fabricmc.loom.configuration.metadata;

+import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -34,11 +37,18 @@ import org.gradle.api.Project;
@@ -34,11 +38,18 @@ import org.gradle.api.Project;
import org.gradle.api.tasks.SourceSet;

import net.fabricmc.loom.LoomGradleExtension;
Expand All @@ -555,7 +556,7 @@ index 923c7a30d4d9785dbf26ef3f59f044197a53abe1..490240ac688d7fddba464b70005d7c23
final LoomGradleExtension extension = LoomGradleExtension.get(project);
var sourceSets = new ArrayList<SourceSet>();
sourceSets.add(SourceSetHelper.getMainSourceSet(project));
@@ -48,10 +58,10 @@ public class FabricModJsonHelpers {
@@ -48,10 +59,10 @@ public class FabricModJsonHelpers {
}

try {
Expand All @@ -569,7 +570,7 @@ index 923c7a30d4d9785dbf26ef3f59f044197a53abe1..490240ac688d7fddba464b70005d7c23
}
} catch (IOException e) {
throw new UncheckedIOException(e);
@@ -59,4 +69,24 @@ public class FabricModJsonHelpers {
@@ -59,4 +70,32 @@ public class FabricModJsonHelpers {

return Collections.emptyList();
}
Expand All @@ -587,7 +588,15 @@ index 923c7a30d4d9785dbf26ef3f59f044197a53abe1..490240ac688d7fddba464b70005d7c23
+ }
+
+ public static boolean isQuiltMod(Path jar) {
+ return ZipUtils.contains(jar, QUILT_MOD_JSON);
+ try {
+ return ZipUtils.contains(jar, QUILT_MOD_JSON);
+ } catch (UncheckedIOException e) {
+ if (e.getCause() instanceof FileNotFoundException) {
+ return false;
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ public static String getMetadataPath(Path jar) {
Expand Down

0 comments on commit 5fa3580

Please sign in to comment.