Skip to content

Commit

Permalink
remove listener when logging out (#118)
Browse files Browse the repository at this point in the history
* remove listener when logging out
  • Loading branch information
WaitingIdly authored Oct 11, 2024
1 parent 48ba60f commit a3712fd
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 @@ -725,6 +725,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());
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 a3712fd

Please sign in to comment.