Skip to content

Commit

Permalink
fix cleanup handling in permission cache
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Dec 31, 2024
1 parent 7249f48 commit 2175d87
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions shared/src/main/java/me/xginko/aef/utils/CachingPermTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,21 @@ public static boolean hasPermission(AEFPermission permission, HumanEntity human)

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onLeave(PlayerQuitEvent event) {
Cache<AEFPermission, Boolean> cache = permissionCacheMap.remove(event.getPlayer().getUniqueId());
cache.invalidateAll();
cache.cleanUp();
if (permissionCacheMap.containsKey(event.getPlayer().getUniqueId())) {
Cache<AEFPermission, Boolean> cache = permissionCacheMap.get(event.getPlayer().getUniqueId());
cache.invalidateAll();
cache.cleanUp();
permissionCacheMap.remove(event.getPlayer().getUniqueId());
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onKick(PlayerKickEvent event) {
Cache<AEFPermission, Boolean> cache = permissionCacheMap.remove(event.getPlayer().getUniqueId());
cache.invalidateAll();
cache.cleanUp();
if (permissionCacheMap.containsKey(event.getPlayer().getUniqueId())) {
Cache<AEFPermission, Boolean> cache = permissionCacheMap.get(event.getPlayer().getUniqueId());
cache.invalidateAll();
cache.cleanUp();
permissionCacheMap.remove(event.getPlayer().getUniqueId());
}
}
}

0 comments on commit 2175d87

Please sign in to comment.