Simplify further as using ConcurrentHashMap

Dieser Commit ist enthalten in:
dordsor21 2020-10-01 17:08:29 +01:00
Ursprung 197e08a937
Commit 88e64a0632
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B

Datei anzeigen

@ -19,26 +19,16 @@ public class BukkitPermissionAttachmentManager {
if (p == null) { if (p == null) {
return null; return null;
} }
PermissionAttachment attachment = attachments.get(p); return attachments.computeIfAbsent(p, k -> k.addAttachment(plugin));
if (attachment != null) {
return attachment;
}
synchronized (this) {
return attachments.computeIfAbsent(p, k -> k.addAttachment(plugin));
}
} }
public void removeAttachment(@Nullable final Player p) { public void removeAttachment(@Nullable final Player p) {
if (p == null || attachments.get(p) == null) { if (p == null) {
return; return;
} }
synchronized (this) { PermissionAttachment attach = attachments.remove(p);
PermissionAttachment attach = attachments.remove(p); if (attach != null) {
if (attach != null) { p.removeAttachment(attach);
p.removeAttachment(attach);
}
} }
} }
} }