diff options
Diffstat (limited to 'src')
8 files changed, 152 insertions, 3 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(); } diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 028a9e65..d080d7f5 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -54,6 +54,8 @@ "AccessorMinecraft", "MixinEntityChargedCreeper", "MixinGuiEditSign", - "MixinGuiTextField" + "MixinGuiTextField", + "MixinThreadDownloadImageData", + "MixinThreadDownloadImageDataThread" ] } diff --git a/src/main/resources/neukeystore.jks b/src/main/resources/neukeystore.jks Binary files differindex 3a5a23b6..b71185af 100644 --- a/src/main/resources/neukeystore.jks +++ b/src/main/resources/neukeystore.jks diff --git a/src/main/resources/neukeystore.txt b/src/main/resources/neukeystore.txt index 5616f69b..a64accd0 100644 --- a/src/main/resources/neukeystore.txt +++ b/src/main/resources/neukeystore.txt @@ -13,5 +13,7 @@ Please keep a list of added aliases below: - ISRGROOTX1 (Let's Encrypt) - ISRGROOTX2 (Let's Encrypt) + - MSRSAROOT (Microsoft Root CA 2017) + - DIGIROOTG2 (DigiCert Global Root G2) |