Skip to content

Commit

Permalink
remove listener when logging out
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly committed Jun 23, 2024
1 parent f5960d5 commit 622e240
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/betterquesting/handlers/EventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,12 @@ public void onEntityCreated(EntityJoinWorldEvent event) {
PlayerContainerListener.refreshListener((EntityPlayer) event.getEntity());
}

@SubscribeEvent
public static 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 622e240

Please sign in to comment.