diff --git a/src/main/java/betterquesting/handlers/EventHandler.java b/src/main/java/betterquesting/handlers/EventHandler.java index 706f74538..75af9384a 100644 --- a/src/main/java/betterquesting/handlers/EventHandler.java +++ b/src/main/java/betterquesting/handlers/EventHandler.java @@ -724,6 +724,12 @@ public void onEntityCreated(EntityJoinWorldEvent event) { PlayerContainerListener.refreshListener((EntityPlayer) event.getEntity()); } + @SubscribeEvent + public void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent event) { + if (event.player == null || event.player.world.isRemote) return; + PlayerContainerListener.removeListener(event.player); + } + @SubscribeEvent public void onMarkDirtyPlayer(MarkDirtyPlayerEvent event) { SaveLoadHandler.INSTANCE.addDirtyPlayers(event.getDirtyPlayerIDs()); diff --git a/src/main/java/betterquesting/handlers/PlayerContainerListener.java b/src/main/java/betterquesting/handlers/PlayerContainerListener.java index ef90eb88b..3354a9411 100644 --- a/src/main/java/betterquesting/handlers/PlayerContainerListener.java +++ b/src/main/java/betterquesting/handlers/PlayerContainerListener.java @@ -37,6 +37,11 @@ public static void refreshListener(@Nonnull EntityPlayer player) { } } + public static void removeListener(@Nonnull EntityPlayer player) { + UUID uuid = QuestingAPI.getQuestingUUID(player); + LISTEN_MAP.remove(uuid); + } + private EntityPlayer player; private PlayerContainerListener(@Nonnull EntityPlayer player) {