Add in proper handling of equals and hashcode for modjar urls. Fixes very slow loading on windows.

Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
cpw 2020-10-26 18:00:14 -04:00
parent 7205c30ece
commit 6982c5dd56
No known key found for this signature in database
GPG key ID: 8EB3DF749553B1B7

View file

@ -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;