From 6982c5dd56fc5e2a1608a97d99bd1fc22d8ef955 Mon Sep 17 00:00:00 2001 From: cpw Date: Mon, 26 Oct 2020 18:00:14 -0400 Subject: [PATCH] Add in proper handling of equals and hashcode for modjar urls. Fixes very slow loading on windows. Signed-off-by: cpw --- .../fml/loading/ModJarURLHandler.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModJarURLHandler.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/ModJarURLHandler.java index c917aa81e..71184646b 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/ModJarURLHandler.java +++ b/src/fmllauncher/java/net/minecraftforge/fml/loading/ModJarURLHandler.java @@ -30,6 +30,7 @@ import java.net.URLConnection; import java.net.URLStreamHandler; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; import java.util.Optional; import java.util.jar.Manifest; @@ -44,6 +45,18 @@ public class ModJarURLHandler extends URLStreamHandler return new ModJarURLConnection(url); } + @Override + protected int hashCode(final URL u) { + return Objects.hash(u.getHost(), u.getFile()); + } + + @Override + protected boolean equals(final URL u1, final URL u2) { + return Objects.equals(u1.getProtocol(), u2.getProtocol()) + && Objects.equals(u1.getHost(), u2.getHost()) + && Objects.equals(u1.getFile(), u2.getFile()); + } + static class ModJarURLConnection extends URLConnection { private Path resource; private String modpath;