aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung
diff options
context:
space:
mode:
authorsyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-08 23:12:38 +0900
committersyeyoung <42869671+cyoung06@users.noreply.github.com>2020-12-08 23:12:38 +0900
commita00a2cfed6980a5f71c40a3df1cb5cb69e87f17d (patch)
tree98db3fe82d04fad84a64cf24ceff8c75bb982807 /src/main/java/kr/syeyoung
parentf6a3ae6948b940d0bcc2deddde37cdf2349cfa46 (diff)
downloadSkyblock-Dungeons-Guide-a00a2cfed6980a5f71c40a3df1cb5cb69e87f17d.tar.gz
Skyblock-Dungeons-Guide-a00a2cfed6980a5f71c40a3df1cb5cb69e87f17d.tar.bz2
Skyblock-Dungeons-Guide-a00a2cfed6980a5f71c40a3df1cb5cb69e87f17d.zip
interesting
Diffstat (limited to 'src/main/java/kr/syeyoung')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java104
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java15
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java44
4 files changed, 91 insertions, 76 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
index cc2a6243..bf1a05a9 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/Authenticator.java
@@ -105,6 +105,8 @@ public class Authenticator {
return new BigInteger(result).toString(16);
}
public InputStream getInputStream(String resource) throws IOException, BadPaddingException, IllegalBlockSizeException, NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException {
+ System.out.println("loading "+resource);
+
HttpURLConnection huc = (HttpURLConnection) new URL(DOMAIN+"resource/resource?class="+ URLEncoder.encode(resource)).openConnection();
huc.setRequestProperty("User-Agent", "DungeonsGuide/1.0");
huc.setRequestProperty("Content-Type", "application/json");
@@ -119,11 +121,9 @@ public class Authenticator {
((bytes[1] & 0xFF) << 16) |
((bytes[2] & 0xFF) << 8 ) |
((bytes[3] & 0xFF));
- System.out.println(len);
while(inputStream.available() < len);
byte[] pubKey = new byte[len];
inputStream.read(pubKey);
- System.out.println(DatatypeConverter.printBase64Binary(pubKey));
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
byte[] byteEncrypted = pubKey;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
index 33e3d3e6..a2207c6b 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/DungeonsGuide.java
@@ -8,6 +8,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.launchwrapper.LaunchClassLoader;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.GuiOpenEvent;
@@ -48,68 +49,39 @@ public class DungeonsGuide
@EventHandler
public void init(FMLInitializationEvent event)
{
- dungeonsGuide = this;
- skyblockStatus = new SkyblockStatus();
- MinecraftForge.EVENT_BUS.register(new EventListener());
- CommandEditRoom cc = new CommandEditRoom();
- ClientCommandHandler.instance.registerCommand(cc);
- MinecraftForge.EVENT_BUS.register(cc);
- ClientCommandHandler.instance.registerCommand(new CommandLoadData());
- ClientCommandHandler.instance.registerCommand(new CommandSaveData());
- ClientCommandHandler.instance.registerCommand(new CommandToggleDebug());
- ClientCommandHandler.instance.registerCommand(new CommandWhatYearIsIt());
-
- if (!configDir.exists()) {
- //noinspection ResultOfMethodCallIgnored
- configDir.mkdirs();
- String[] files = {
- "990f6e4c-f7cf-4d27-ae91-11219b85861f.roomdata",
- "5000be9d-3081-4a5e-8563-dd826705663a.roomdata",
- "9139cb1c-b6f3-4bac-92de-909b1eb73449.roomdata",
- "11982f7f-703e-4d98-9d27-4e07ba3fef71.roomdata",
- "a053f4fa-d6b2-4aef-ae3e-97c7eee0252e.roomdata",
- "c2ea0a41-d495-437f-86cc-235a71c49f22.roomdata",
- "cf6d49d3-4f1e-4ec9-836e-049573793ddd.roomdata",
- "cf44c95c-950e-49e0-aa4c-82c2b18d0acc.roomdata",
- "d3e61abf-4198-4520-a950-a03761a0eb6f.roomdata",
- "ffd5411b-6ff4-4f60-b387-72f00510ec50.roomdata",
- "b2dce4ed-2bda-4303-a4d7-3ebb914db318.roomdata"
- };
- for (String str:files) {
- try {
- copy(DungeonsGuide.class.getResourceAsStream("/roomdata/"+str), new File(configDir, str));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ Class skyblockStatusCls = null;
try {
- DungeonRoomInfoRegistry.loadAll();
- } catch (BadPaddingException e) {
- e.printStackTrace();
- } catch (InvalidAlgorithmParameterException e) {
- e.printStackTrace();
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (IllegalBlockSizeException e) {
- e.printStackTrace();
- } catch (NoSuchPaddingException e) {
- e.printStackTrace();
- } catch (InvalidKeyException e) {
+ skyblockStatusCls = classLoader.findClass("kr.syeyoung.dungeonsguide.SkyblockStatus");
+ } catch (ClassNotFoundException e) {
e.printStackTrace();
+
+ error(new String[]{
+ "Couldn't load Dungeons Guide",
+ "Please contact developer if this problem persists after restart"
+ });
+ return;
}
- Keybinds.register();
- }
+ dungeonsGuide = this;
+ try {
+ skyblockStatus = skyblockStatusCls.newInstance();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
- private void copy(InputStream inputStream, File f) throws IOException {
- FileOutputStream fos = new FileOutputStream(f);
- IOUtils.copy(inputStream, fos);
- fos.flush();
- fos.close();
- inputStream.close();
+ error(new String[]{
+ "Couldn't load Dungeons Guide",
+ "Please contact developer if this problem persists after restart"
+ });
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+
+ error(new String[]{
+ "Couldn't load Dungeons Guide",
+ "Please contact developer if this problem persists after restart"
+ });
+ }
}
@Getter
@@ -120,6 +92,7 @@ public class DungeonsGuide
private NetworkClassLoader classLoader;
@EventHandler
public void pre(FMLPreInitializationEvent event) {
+ System.out.println(DungeonsGuide.class.getClassLoader());
configDir = new File(event.getModConfigurationDirectory(),"dungeonsguide");
authenticator = new Authenticator();
@@ -128,8 +101,7 @@ public class DungeonsGuide
token = authenticator.authenticate();
System.out.println(token);
if (token != null) {
- classLoader = new NetworkClassLoader(authenticator);
- Thread.currentThread().setContextClassLoader(classLoader);
+ classLoader = new NetworkClassLoader(authenticator, DungeonsGuide.class.getClassLoader());
return;
}
} catch (IOException e) {
@@ -140,6 +112,14 @@ public class DungeonsGuide
e.printStackTrace();
}
+ error(new String[]{
+ "Can't validate current installation of Dungeons Guide",
+ "Please contact mod author if you purchased this mod and getting this error",
+ "And if you haven't purchased the mod, please consider doing so"
+ });
+ }
+
+ public void error(final String[] s_msg) {
final GuiScreen errorGui = new GuiErrorScreen(null, null) {
@Override
@@ -153,11 +133,6 @@ public class DungeonsGuide
@Override
public void drawScreen(int par1, int par2, float par3) {
drawDefaultBackground();
- String[] s_msg = new String[] {
- "Can't validate current installation of Dungeons Guide",
- "Please contact mod author if you purchased this mod and getting this error",
- "And if you haven't purchased the mod, please consider doing so"
- };
for (int i = 0; i < s_msg.length; ++i) {
drawCenteredString(fontRendererObj, s_msg[i], width / 2, height / 3 + 12 * i, 0xFFFFFFFF);
}
@@ -176,7 +151,6 @@ public class DungeonsGuide
};
throw e;
}
-
public Object getSkyblockStatus() {
return (SkyblockStatus) skyblockStatus;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java b/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
index e3a7e255..f8f80611 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/NetworkClassLoader.java
@@ -3,10 +3,7 @@ package kr.syeyoung.dungeonsguide;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@@ -14,8 +11,8 @@ import java.security.NoSuchAlgorithmException;
public class NetworkClassLoader extends ClassLoader {
Authenticator authenticator;
- public NetworkClassLoader(Authenticator authenticator) {
- super();
+ public NetworkClassLoader(Authenticator authenticator, ClassLoader parent) {
+ super(parent);
this.authenticator = authenticator;
}
@@ -25,7 +22,8 @@ public class NetworkClassLoader extends ClassLoader {
try {
b = loadClassFromFile(name);
return defineClass(name, b, 0, b.length);
- } catch (BadPaddingException e) {
+ } catch (FileNotFoundException ignored) {
+ } catch(BadPaddingException e) {
e.printStackTrace();
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
@@ -51,6 +49,7 @@ public class NetworkClassLoader extends ClassLoader {
length |= (inputStream.read() & 0xFF) << i * 8;
}
}
+ while (inputStream.available() < length);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
int nextValue = 0;
@@ -59,7 +58,7 @@ public class NetworkClassLoader extends ClassLoader {
while ( (inputStream.read(buffer)) != -1 ) {
byteStream.write(buffer);
}
- } catch (Exception e) {}
+ } catch (Exception ignored) {}
byte[] byte1 = byteStream.toByteArray();
byte[] byte2 = new byte[(int) length];
System.arraycopy(byte1, 0, byte2, 0, byte2.length);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java b/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java
index eb728271..2710a5b2 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/SkyblockStatus.java
@@ -1,13 +1,25 @@
package kr.syeyoung.dungeonsguide;
import com.google.common.collect.Sets;
+import kr.syeyoung.dungeonsguide.commands.*;
import kr.syeyoung.dungeonsguide.dungeon.DungeonContext;
+import kr.syeyoung.dungeonsguide.dungeon.roomfinder.DungeonRoomInfoRegistry;
import kr.syeyoung.dungeonsguide.utils.TextUtils;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.scoreboard.*;
-
+import net.minecraftforge.client.ClientCommandHandler;
+import net.minecraftforge.common.MinecraftForge;
+
+import javax.crypto.BadPaddingException;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import java.io.File;
+import java.io.IOException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Set;
import java.util.regex.Matcher;
@@ -28,6 +40,36 @@ public class SkyblockStatus {
private final Pattern SERVER_BRAND_PATTERN = Pattern.compile("(.+) <- (?:.+)");
+ public SkyblockStatus() {
+ MinecraftForge.EVENT_BUS.register(new EventListener());
+ CommandEditRoom cc = new CommandEditRoom();
+ ClientCommandHandler.instance.registerCommand(cc);
+ MinecraftForge.EVENT_BUS.register(cc);
+ ClientCommandHandler.instance.registerCommand(new CommandLoadData());
+ ClientCommandHandler.instance.registerCommand(new CommandSaveData());
+ ClientCommandHandler.instance.registerCommand(new CommandToggleDebug());
+ ClientCommandHandler.instance.registerCommand(new CommandWhatYearIsIt());
+
+ try {
+ DungeonRoomInfoRegistry.loadAll();
+ } catch (BadPaddingException e) {
+ e.printStackTrace();
+ } catch (InvalidAlgorithmParameterException e) {
+ e.printStackTrace();
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (IllegalBlockSizeException e) {
+ e.printStackTrace();
+ } catch (NoSuchPaddingException e) {
+ e.printStackTrace();
+ } catch (InvalidKeyException e) {
+ e.printStackTrace();
+ }
+
+ Keybinds.register();
+ }
public boolean isOnHypixel() {