aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java40
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java48
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageDataThread.java46
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java7
5 files changed, 147 insertions, 2 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java b/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java
new file mode 100644
index 00000000..4fa57360
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2022 Linnea Gräf
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.hooks;
+
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.util.ApiUtil;
+
+import javax.net.ssl.HttpsURLConnection;
+import java.net.HttpURLConnection;
+
+public class ThreadDownloadImageHook {
+ public static void hookThreadImageConnection(HttpURLConnection connection) {
+ if ((connection instanceof HttpsURLConnection) && NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls) {
+ ApiUtil.patchHttpsRequest((HttpsURLConnection) connection);
+ }
+ }
+
+ public static String hookThreadImageLink(String originalLink) {
+ if (!NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls || originalLink == null)
+ return originalLink;
+ return originalLink.replace("http://", "https://");
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
new file mode 100644
index 00000000..c6d25a9e
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2022 Linnea Gräf
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.mixins;
+
+import io.github.moulberry.notenoughupdates.hooks.ThreadDownloadImageHook;
+import net.minecraft.client.renderer.ThreadDownloadImageData;
+import org.spongepowered.asm.lib.Opcodes;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Mutable;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+@Mixin(ThreadDownloadImageData.class)
+public class MixinThreadDownloadImageData {
+ @Mutable
+ @Shadow
+ @Final
+ private String imageUrl;
+
+ @Redirect(
+ method = "<init>",
+ at = @At(
+ value = "FIELD",
+ target = "Lnet/minecraft/client/renderer/ThreadDownloadImageData;imageUrl:Ljava/lang/String;",
+ opcode = Opcodes.PUTFIELD))
+ public void useHttpsDownloadLinks(ThreadDownloadImageData instance, String value) {
+ this.imageUrl = ThreadDownloadImageHook.hookThreadImageLink(value);
+ }
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageDataThread.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageDataThread.java
new file mode 100644
index 00000000..aea52378
--- /dev/null
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageDataThread.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2022 Linnea Gräf
+ *
+ * This file is part of NotEnoughUpdates.
+ *
+ * NotEnoughUpdates is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * NotEnoughUpdates is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package io.github.moulberry.notenoughupdates.mixins;
+
+import io.github.moulberry.notenoughupdates.hooks.ThreadDownloadImageHook;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
+import java.net.HttpURLConnection;
+
+@Mixin(targets = "net.minecraft.client.renderer.ThreadDownloadImageData$1")
+public class MixinThreadDownloadImageDataThread {
+
+ @Inject(
+ method = "run",
+ at = @At(
+ value = "INVOKE",
+ target = "Ljava/net/HttpURLConnection;setDoOutput(Z)V"
+ ),
+ locals = LocalCapture.CAPTURE_FAILSOFT
+ )
+ public void patchHttpConnection(CallbackInfo ci, HttpURLConnection httpURLConnection) {
+ ThreadDownloadImageHook.hookThreadImageConnection(httpURLConnection);
+ }
+
+}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
index 62f5a81a..b72610b8 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Misc.java
@@ -55,6 +55,14 @@ public class Misc {
@ConfigEditorBoolean
public boolean streamerMode = false;
+ @Expose
+ @ConfigOption(
+ name = "Fix Steve skulls",
+ desc = "Fix some skulls and skins not downloading on old java versions. May require restart."
+ )
+ @ConfigEditorBoolean
+ public boolean fixSteveSkulls = true;
+
@ConfigOption(
name = "Fairy Soul Waypoints",
desc = ""
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java
index e84c1c43..c86ac84f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java
@@ -162,8 +162,7 @@ public class ApiUtil {
try {
conn = url.openConnection();
if (conn instanceof HttpsURLConnection && ctx != null) {
- HttpsURLConnection sslConn = (HttpsURLConnection) conn;
- sslConn.setSSLSocketFactory(ctx.getSocketFactory());
+ patchHttpsRequest((HttpsURLConnection) conn);
}
if (conn instanceof HttpURLConnection) {
((HttpURLConnection) conn).setRequestMethod(method);
@@ -221,6 +220,10 @@ public class ApiUtil {
}
+ public static void patchHttpsRequest(HttpsURLConnection connection) {
+ connection.setSSLSocketFactory(ctx.getSocketFactory());
+ }
+
public Request request() {
return new Request();
}