diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-09 12:22:34 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-09 12:22:34 +0900 |
commit | d165e145f7066bd46e2a0b2b0fd0752ba7156cae (patch) | |
tree | 6a158a05f987c37da35b8021484bc9ed31c49de5 /src/main/java/kr/syeyoung | |
parent | 8f8fd536fa34fee9a941408b05e5d55c6d6e77f6 (diff) | |
download | Skyblock-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')
3 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideMain.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideMain.java index c1f3966f..e46e49b7 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideMain.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuideMain.java @@ -48,7 +48,7 @@ public class DungeonsGuideMain if (token != null) { URL.setURLStreamHandlerFactory(new DGURLStreamHandlerFactory()); LaunchClassLoader launchClassLoader = (LaunchClassLoader) DungeonsGuideMain.class.getClassLoader(); - launchClassLoader.addURL(new URL("dungeonsguide://"+token+"@/")); + launchClassLoader.addURL(new URL("dungeonsguide:///")); try { dungeonsGuideInterface = new DungeonsGuide(); 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); diff --git a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java index 83b9d395..b5bc69ea 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/dungeon/roomfinder/DungeonRoomInfoRegistry.java @@ -69,7 +69,7 @@ public class DungeonRoomInfoRegistry { registered.clear(); shapeMap.clear(); uuidMap.clear(); - URL url = new URL("dungeonsguide://"+DungeonsGuideMain.getDungeonsGuideMain().getAuthenticator().getToken()+"@/roomdata/data.txt"); + URL url = new URL("dungeonsguide://"+DungeonsGuideMain.getDungeonsGuideMain().getAuthenticator().getToken()+"@/roomdatas/data.txt"); List<String> lines = IOUtils.readLines(url.openConnection().getInputStream()); for (String name : lines) { if (name.endsWith(".roomdata")) continue; |