From 88e64a063296b618723f3312fea94d0f3d795ebf Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 1 Oct 2020 17:08:29 +0100 Subject: [PATCH] Simplify further as using ConcurrentHashMap --- .../BukkitPermissionAttachmentManager.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPermissionAttachmentManager.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPermissionAttachmentManager.java index fdcf408ea..d1bc5fb1b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPermissionAttachmentManager.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPermissionAttachmentManager.java @@ -19,26 +19,16 @@ public class BukkitPermissionAttachmentManager { if (p == null) { return null; } - PermissionAttachment attachment = attachments.get(p); - - if (attachment != null) { - return attachment; - } - - synchronized (this) { - return attachments.computeIfAbsent(p, k -> k.addAttachment(plugin)); - } + return attachments.computeIfAbsent(p, k -> k.addAttachment(plugin)); } public void removeAttachment(@Nullable final Player p) { - if (p == null || attachments.get(p) == null) { + if (p == null) { return; } - synchronized (this) { - PermissionAttachment attach = attachments.remove(p); - if (attach != null) { - p.removeAttachment(attach); - } + PermissionAttachment attach = attachments.remove(p); + if (attach != null) { + p.removeAttachment(attach); } } }