aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xloader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java15
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideUnloadingException.java2
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java17
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java12
-rw-r--r--loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java14
-rwxr-xr-xmod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java8
6 files changed, 44 insertions, 24 deletions
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
index 16adb3ad..bdd2c21d 100755
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java
@@ -130,6 +130,7 @@ public class Main
try {
unload();
} catch (Exception e2) {
+ e2.printStackTrace();
GuiDisplayer.INSTANCE.displayGui(new GuiUnloadingError(e2));
}
GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e));
@@ -145,11 +146,6 @@ public class Main
for (DungeonsGuideReloadListener listener : listeners) {
listener.unloadReference();
}
- if (currentLoader != null) {
- currentLoader.unloadDungeonsGuide();
- }
- currentLoader = null;
-
NotificationManager.INSTANCE.updateNotification(dgUnloaded, Notification.builder()
.title("Dungeons Guide Not Loaded")
@@ -172,6 +168,7 @@ public class Main
try {
unload();
} catch (Exception e2) {
+ e2.printStackTrace();
GuiDisplayer.INSTANCE.displayGui(new GuiUnloadingError(e2));
}
GuiDisplayer.INSTANCE.displayGui(new GuiLoadingError(e));
@@ -181,6 +178,12 @@ public class Main
})
.unremovable(true)
.build());
+ if (currentLoader != null) {
+ currentLoader.unloadDungeonsGuide();
+ }
+ currentLoader = null;
+
+
}
private void load(IDGLoader newLoader) throws DungeonsGuideLoadingException {
if (dgInterface != null) throw new IllegalStateException("DG is loaded");
@@ -237,7 +240,7 @@ public class Main
load(newLoader);
} catch (DungeonsGuideLoadingException | DungeonsGuideUnloadingException e) {
dgInterface = null;
- currentLoader = null;
+// currentLoader = null;
e.printStackTrace();
throw e;
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideUnloadingException.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideUnloadingException.java
index 6b2850f6..78beeaa7 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideUnloadingException.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/exceptions/DungeonsGuideUnloadingException.java
@@ -20,5 +20,5 @@ package kr.syeyoung.dungeonsguide.launcher.exceptions;
public class DungeonsGuideUnloadingException extends Exception {
public DungeonsGuideUnloadingException(String message) {super(message);}
- public DungeonsGuideUnloadingException(Exception cause) {super(cause);}
+ public DungeonsGuideUnloadingException(Throwable cause) {super(cause);}
}
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java
index 608238a1..eef478d1 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java
@@ -60,7 +60,7 @@ public class JarLoader implements IDGLoader {
@Override
public InputStream convert(String name) { // / separated
- if (this.loadedResources.containsKey(name.substring(1)))
+ if (this.loadedResources.containsKey(name))
return new ByteArrayInputStream(this.loadedResources.get(name));
return null;
}
@@ -74,11 +74,11 @@ public class JarLoader implements IDGLoader {
try {
classLoader = new JarClassLoader((LaunchClassLoader) this.getClass().getClassLoader(), new ZipInputStream(JarLoader.class.getResourceAsStream("/mod.jar")));
-
- dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance();
phantomReference = new PhantomReference<>(classLoader, refQueue);
+ dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance();
+
return dgInterface;
- } catch (Exception e) {
+ } catch (Throwable e) {
throw new DungeonsGuideLoadingException(e);
}
}
@@ -90,12 +90,17 @@ public class JarLoader implements IDGLoader {
@Override
public void unloadDungeonsGuide() throws DungeonsGuideUnloadingException {
+ if (dgInterface == null && classLoader == null) return;
+
try {
+ if (dgInterface != null)
dgInterface.unload();
- } catch (Exception e) {
+ } catch (Throwable e) {
+ dgInterface = null;
throw new DungeonsGuideUnloadingException(e);
}
- classLoader.cleanup();
+ if (classLoader != null)
+ classLoader.cleanup();
classLoader = null;
dgInterface = null;
System.gc();// pls do
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java
index 42d27b76..caf841a8 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java
@@ -66,11 +66,11 @@ public class LocalLoader implements IDGLoader {
try {
classLoader = new LocalClassLoader((LaunchClassLoader) this.getClass().getClassLoader());
-
- dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance();
phantomReference = new PhantomReference<>(classLoader, refQueue);
+ dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance();
+
return dgInterface;
- } catch (Exception e) {
+ } catch (Throwable e) {
throw new DungeonsGuideLoadingException(e);
}
}
@@ -82,11 +82,15 @@ public class LocalLoader implements IDGLoader {
@Override
public void unloadDungeonsGuide() throws DungeonsGuideUnloadingException {
+ if (dgInterface == null && classLoader == null) return;
try {
+ if (dgInterface != null)
dgInterface.unload();
- } catch (Exception e) {
+ } catch (Throwable e) {
+ dgInterface = null;
throw new DungeonsGuideUnloadingException(e);
}
+ if (classLoader != null)
classLoader.cleanup();
classLoader = null;
dgInterface = null;
diff --git a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java
index cf0379a5..12bb2b71 100644
--- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java
+++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java
@@ -71,7 +71,7 @@ public class RemoteLoader implements IDGLoader {
@Override
public InputStream convert(String name) { // / separated
- if (this.loadedResources.containsKey(name.substring(1)))
+ if (this.loadedResources.containsKey(name))
return new ByteArrayInputStream(this.loadedResources.get(name));
return null;
}
@@ -102,11 +102,11 @@ public class RemoteLoader implements IDGLoader {
SignatureValidator.validateVersion1Signature(target, mod, signature);
classLoader = new JarClassLoader((LaunchClassLoader) this.getClass().getClassLoader(), new ZipInputStream(new ByteArrayInputStream(mod)));
-
- dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance();
phantomReference = new PhantomReference<>(classLoader, refQueue);
+ dgInterface = (DGInterface) classLoader.loadClass("kr.syeyoung.dungeonsguide.mod.DungeonsGuide", true).newInstance();
+
return dgInterface;
- } catch (Exception e) {
+ } catch (Throwable e) { // the reason why I am catching throwable here: in case NoClassDefFoundError.
throw new DungeonsGuideLoadingException(e);
}
}
@@ -118,11 +118,15 @@ public class RemoteLoader implements IDGLoader {
@Override
public void unloadDungeonsGuide() throws DungeonsGuideUnloadingException {
+ if (dgInterface == null && classLoader == null) return;
try {
+ if (dgInterface != null)
dgInterface.unload();
- } catch (Exception e) {
+ } catch (Throwable e) {
+ dgInterface = null;
throw new DungeonsGuideUnloadingException(e);
}
+ if (classLoader != null)
classLoader.cleanup();
classLoader = null;
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java
index fad86a11..4864fa53 100755
--- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java
+++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java
@@ -338,7 +338,7 @@ public class DungeonsGuide implements DGInterface {
e.printStackTrace();
}
NetHandlerPlayClient netHandlerPlayClient = Minecraft.getMinecraft().getNetHandler();
- if (netHandlerPlayClient == null)
+ if (netHandlerPlayClient == null && (Minecraft.getMinecraft().getRenderManager().livingPlayer) != null)
netHandlerPlayClient = ((EntityPlayerSP) Minecraft.getMinecraft().getRenderManager().livingPlayer).sendQueue;
if (netHandlerPlayClient != null) {
@@ -401,7 +401,11 @@ public class DungeonsGuide implements DGInterface {
} catch (InterruptedException e) {
}
THREAD_GROUP.destroy();
- GameSDK.cleanup();
+ try {
+ GameSDK.cleanup();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
@Override