diff options
3 files changed, 24 insertions, 5 deletions
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 5ef83afa..ea05603f 100755 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/DungeonsGuide.java @@ -69,6 +69,8 @@ import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.ProgressManager; +import net.minecraftforge.fml.common.eventhandler.EventBus; +import net.minecraftforge.fml.common.eventhandler.ListenerList; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.ReflectionHelper; import org.apache.logging.log4j.LogManager; @@ -289,6 +291,13 @@ public class DungeonsGuide implements DGInterface { for (Object registeredListener : registeredListeners) { MinecraftForge.EVENT_BUS.unregister(registeredListener); } + List<ListenerList> all = ReflectionHelper.getPrivateValue(ListenerList.class, null, "allLists"); + int busId = ReflectionHelper.getPrivateValue(EventBus.class, MinecraftForge.EVENT_BUS, "busID"); + for (ListenerList listenerList : all) { + listenerList.getListeners(busId); // refresh cache. + } + + Set<ICommand> commands = ReflectionHelper.getPrivateValue(CommandHandler.class, ClientCommandHandler.instance, "commandSet"); for (ICommand registeredCommand : registeredCommands) { diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java index c6fecb33..0a48ad21 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/gamesdk/GameSDK.java @@ -74,12 +74,21 @@ public class GameSDK { } public static void cleanup() { -// com.sun.jna.CallbackReference has reference of DiscordCallback. idk how i should approach fixing this -> I would better write native lib myself later. - if (System.getProperty("dg.safe") == null) return; - Map infos = ReflectionHelper.getPrivateValue(Structure.class, null, "layoutInfo"); - infos.clear(); + nativeGameSDK = null; Map options = ReflectionHelper.getPrivateValue(Native.class, null, "options"); options.clear(); + try { + Map callbackMap = ReflectionHelper.<Map, Object>getPrivateValue( + (Class<? super Object>) Class.forName("com.sun.jna.CallbackReference"), + null, + "callbackMap" + ); + callbackMap.clear(); + } catch (ClassNotFoundException e) { + } + + Map infos = ReflectionHelper.getPrivateValue(Structure.class, null, "layoutInfo"); + infos.clear(); Map alignments = ReflectionHelper.getPrivateValue(Native.class, null, "alignments"); alignments.clear(); Map<Class, TypeMapper> typeMapperMap = ReflectionHelper.getPrivateValue(Native.class, null, "typeMappers"); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java index 135716f9..1ea17cfe 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/discord/rpc/RichPresenceManager.java @@ -223,7 +223,6 @@ public class RichPresenceManager implements Runnable { }); } } - @Override public void run() { boolean setup = true; @@ -250,5 +249,7 @@ public class RichPresenceManager implements Runnable { Thread.sleep(16L); } catch (Exception e) {e.printStackTrace();} } + if (iDiscordCore != null) + iDiscordCore.Destroy.destroy(iDiscordCore); } } |