aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-02-01 10:01:05 +0100
committernea <nea@nea.moe>2023-02-01 10:37:48 +0100
commit2fdcedce1d43943b212621bdcc3d335c5ea011e9 (patch)
tree160e341c6fad454385ebea48e9b0c661be4965a9
parent13452658006ba945cec1491cb198f05b2258af93 (diff)
downloadNotEnoughUpdates-texturefixv2.tar.gz
NotEnoughUpdates-texturefixv2.tar.bz2
NotEnoughUpdates-texturefixv2.zip
Restrict texture https upgrading to only minecraft.nettexturefixv2
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java17
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java17
2 files changed, 27 insertions, 7 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
index 4fa57360..e84fce11 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/hooks/ThreadDownloadImageHook.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Linnea Gräf
+ * Copyright (C) 2022-2023 Linnea Gräf
*
* This file is part of NotEnoughUpdates.
*
@@ -26,15 +26,22 @@ import javax.net.ssl.HttpsURLConnection;
import java.net.HttpURLConnection;
public class ThreadDownloadImageHook {
+ public static String hookThreadImageLink(String originalLink) {
+ if (!NotEnoughUpdates.INSTANCE.config.misc.fixSteveSkulls || originalLink == null || !originalLink.startsWith(
+ "http://textures.minecraft.net"))
+ return originalLink;
+ return originalLink.replace("http://", "https://");
+ }
+
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://");
+ public interface AccessorThreadDownloadImageData {
+ String getOriginalUrl();
+
+ String getPatchedUrl();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
index c6d25a9e..fd4ee495 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinThreadDownloadImageData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 Linnea Gräf
+ * Copyright (C) 2022-2023 Linnea Gräf
*
* This file is part of NotEnoughUpdates.
*
@@ -30,12 +30,14 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ThreadDownloadImageData.class)
-public class MixinThreadDownloadImageData {
+public class MixinThreadDownloadImageData implements ThreadDownloadImageHook.AccessorThreadDownloadImageData{
@Mutable
@Shadow
@Final
private String imageUrl;
+ private String originalUrl;
+
@Redirect(
method = "<init>",
at = @At(
@@ -44,5 +46,16 @@ public class MixinThreadDownloadImageData {
opcode = Opcodes.PUTFIELD))
public void useHttpsDownloadLinks(ThreadDownloadImageData instance, String value) {
this.imageUrl = ThreadDownloadImageHook.hookThreadImageLink(value);
+ this.originalUrl = value;
+ }
+
+ @Override
+ public String getOriginalUrl() {
+ return originalUrl;
+ }
+
+ @Override
+ public String getPatchedUrl() {
+ return imageUrl;
}
}