aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/customurl
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-09 12:22:34 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-09 12:22:34 +0900
commitd165e145f7066bd46e2a0b2b0fd0752ba7156cae (patch)
tree6a158a05f987c37da35b8021484bc9ed31c49de5 /src/main/java/kr/syeyoung/dungeonsguide/customurl
parent8f8fd536fa34fee9a941408b05e5d55c6d6e77f6 (diff)
downloadSkyblock-Dungeons-Guide-d165e145f7066bd46e2a0b2b0fd0752ba7156cae.tar.gz
Skyblock-Dungeons-Guide-d165e145f7066bd46e2a0b2b0fd0752ba7156cae.tar.bz2
Skyblock-Dungeons-Guide-d165e145f7066bd46e2a0b2b0fd0752ba7156cae.zip
more hacky stuff
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/customurl')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java b/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java
index 56eab8c8..404ccdb4 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java
@@ -3,6 +3,7 @@ package kr.syeyoung.dungeonsguide.customurl;
import kr.syeyoung.dungeonsguide.Authenticator;
import kr.syeyoung.dungeonsguide.DungeonsGuideMain;
import lombok.SneakyThrows;
+import net.minecraft.launchwrapper.LaunchClassLoader;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
@@ -22,6 +23,11 @@ public class DGURLConnection extends URLConnection {
protected DGURLConnection(URL url) {
super(url);
+ try {
+ connect();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
@SneakyThrows
@@ -30,12 +36,20 @@ public class DGURLConnection extends URLConnection {
if (!(url.getPath().contains("kr/syeyoung") ||url.getPath().contains("roomdata"))) return;
this.connected = true;
- System.out.println("loading "+url.getPath().substring(1));
+ boolean classLoader = false;
+ for (StackTraceElement ste:Thread.currentThread().getStackTrace()){
+ if (ste.getClassName().equals("net.minecraft.launchwrapper.LaunchClassLoader")) {
+ classLoader = true;
+ }
+ }
+
+
+ System.out.println("loading "+url.getPath().substring(1) +" called from classloader "+classLoader);
HttpURLConnection huc = (HttpURLConnection) new URL(DOMAIN+"resource/resource?class="+ URLEncoder.encode(url.getPath().substring(1))).openConnection();
huc.setRequestProperty("User-Agent", "DungeonsGuide/1.0");
huc.setRequestProperty("Content-Type", "application/json");
- huc.setRequestProperty("Authorization", url.getUserInfo());
+ huc.setRequestProperty("Authorization", (url.getUserInfo() == null && classLoader) ? DungeonsGuideMain.getDungeonsGuideMain().getAuthenticator().getToken() : url.getUserInfo());
huc.setDoInput(true);
huc.setDoOutput(true);