geforkt von Mirrors/FastAsyncWorldEdit
Fix memory leak by Citizen NPCs (#1693)
* fix: ignore uuid v2 for BukkitPermissionAttachmentManager Fixes a memory leak that attaches and caches PermissionAttachments to NPCs. Citiziens uses version 2 UUIDs, which are not used for regular player uuids. Those v2 uuids are now excluded. * fix: create Permission when required * fix: use citizens documented way to check for NPCs
Dieser Commit ist enthalten in:
Ursprung
ed9317b4d6
Commit
2483eacff5
@ -2,6 +2,7 @@ package com.fastasyncworldedit.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -12,6 +13,7 @@ public class BukkitPermissionAttachmentManager {
|
||||
|
||||
private final WorldEditPlugin plugin;
|
||||
private final Map<Player, PermissionAttachment> attachments = new ConcurrentHashMap<>();
|
||||
private PermissionAttachment noopAttachment;
|
||||
|
||||
public BukkitPermissionAttachmentManager(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -21,6 +23,12 @@ public class BukkitPermissionAttachmentManager {
|
||||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
if (p.hasMetadata("NPC")) {
|
||||
if (this.noopAttachment == null) {
|
||||
this.noopAttachment = new PermissionAttachment(plugin, new PermissibleBase(null));
|
||||
}
|
||||
return noopAttachment;
|
||||
}
|
||||
return attachments.computeIfAbsent(p, k -> k.addAttachment(plugin));
|
||||
}
|
||||
|
||||
@ -28,6 +36,10 @@ public class BukkitPermissionAttachmentManager {
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
if (p.hasMetadata("NPC") && noopAttachment != null) {
|
||||
p.removeAttachment(noopAttachment);
|
||||
return;
|
||||
}
|
||||
PermissionAttachment attach = attachments.remove(p);
|
||||
if (attach != null) {
|
||||
p.removeAttachment(attach);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren