From 2175d8717dbe21277daf5c4ea45e6f4fb8eeb5cf Mon Sep 17 00:00:00 2001 From: xGinko Date: Tue, 31 Dec 2024 23:06:36 +0100 Subject: [PATCH] fix cleanup handling in permission cache --- .../me/xginko/aef/utils/CachingPermTool.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/shared/src/main/java/me/xginko/aef/utils/CachingPermTool.java b/shared/src/main/java/me/xginko/aef/utils/CachingPermTool.java index bbd63bdf..75479cb5 100644 --- a/shared/src/main/java/me/xginko/aef/utils/CachingPermTool.java +++ b/shared/src/main/java/me/xginko/aef/utils/CachingPermTool.java @@ -54,15 +54,21 @@ public static boolean hasPermission(AEFPermission permission, HumanEntity human) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) private void onLeave(PlayerQuitEvent event) { - Cache cache = permissionCacheMap.remove(event.getPlayer().getUniqueId()); - cache.invalidateAll(); - cache.cleanUp(); + if (permissionCacheMap.containsKey(event.getPlayer().getUniqueId())) { + Cache 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 cache = permissionCacheMap.remove(event.getPlayer().getUniqueId()); - cache.invalidateAll(); - cache.cleanUp(); + if (permissionCacheMap.containsKey(event.getPlayer().getUniqueId())) { + Cache cache = permissionCacheMap.get(event.getPlayer().getUniqueId()); + cache.invalidateAll(); + cache.cleanUp(); + permissionCacheMap.remove(event.getPlayer().getUniqueId()); + } } }