From 687a179eb178f7e1d1d5d30c92028ddf745357b6 Mon Sep 17 00:00:00 2001 From: syeyoung Date: Fri, 18 Nov 2022 03:23:23 +0900 Subject: - Unload first then null out. - Fix broken condition in Main.obtainLoader Signed-off-by: syeyoung --- loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java | 6 +++--- .../java/kr/syeyoung/dungeonsguide/launcher/loader/JarLoader.java | 2 +- .../java/kr/syeyoung/dungeonsguide/launcher/loader/LocalLoader.java | 2 +- .../kr/syeyoung/dungeonsguide/launcher/loader/RemoteLoader.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'loader/src') 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 2ada9dc8..5724dfa3 100755 --- a/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java +++ b/loader/src/main/java/kr/syeyoung/dungeonsguide/launcher/Main.java @@ -231,7 +231,7 @@ public class Main try { unload(); load(newLoader); - } catch (DungeonsGuideLoadingException | DungeonsGuideUnloadingException | UnsupportedOperationException e) { + } catch (DungeonsGuideLoadingException | DungeonsGuideUnloadingException e) { dgInterface = null; currentLoader = null; @@ -255,10 +255,10 @@ public class Main String loader = getLoaderName(configuration); if ("local".equals(loader) || - (loader.equals("auto") && this.getClass().getResourceAsStream("/kr/syeyoung/dungeonsguide/DungeonsGuide.class") == null)) { + (loader.equals("auto") && this.getClass().getResourceAsStream("/kr/syeyoung/dungeonsguide/DungeonsGuide.class") != null)) { return new LocalLoader(); } else if ("jar".equals(loader) || - (loader.equals("auto") && this.getClass().getResourceAsStream("/mod.jar") == null)) { + (loader.equals("auto") && this.getClass().getResourceAsStream("/mod.jar") != null)) { return new JarLoader(); } else if (loader.equals("remote") || loader.equals("auto") ){ // remote load 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 61dec833..df450af6 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 @@ -89,12 +89,12 @@ public class JarLoader implements IDGLoader { @Override public void unloadDungeonsGuide() throws DungeonsGuideUnloadingException { - classLoader = null; try { dgInterface.unload(); } catch (Exception e) { throw new DungeonsGuideUnloadingException(e); } + classLoader = null; dgInterface = null; System.gc();// pls do Reference t = refQueue.poll(); 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 519578f1..005a6005 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 @@ -81,12 +81,12 @@ public class LocalLoader implements IDGLoader { @Override public void unloadDungeonsGuide() throws DungeonsGuideUnloadingException { - classLoader = null; try { dgInterface.unload(); } catch (Exception e) { throw new DungeonsGuideUnloadingException(e); } + classLoader = null; dgInterface = null; System.gc();// pls do Reference t = refQueue.poll(); 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 e4becc53..575a31b3 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 @@ -122,13 +122,13 @@ public class RemoteLoader implements IDGLoader { @Override public void unloadDungeonsGuide() throws DungeonsGuideUnloadingException { - classLoader = null; - try { dgInterface.unload(); } catch (Exception e) { throw new DungeonsGuideUnloadingException(e); } + classLoader = null; + dgInterface = null; System.gc();// pls do Reference t = refQueue.poll(); -- cgit