mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 10:17:38 +01:00
Don't lazy-load in PermissibleBase. This'll be a performance hit, but it's causing subscription issues.
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
3fd400d31d
commit
f82dfdc717
@ -18,7 +18,6 @@ public class PermissibleBase implements Permissible {
|
|||||||
private Permissible parent = this;
|
private Permissible parent = this;
|
||||||
private final List<PermissionAttachment> attachments = new LinkedList<PermissionAttachment>();
|
private final List<PermissionAttachment> attachments = new LinkedList<PermissionAttachment>();
|
||||||
private final Map<String, PermissionAttachmentInfo> permissions = new HashMap<String, PermissionAttachmentInfo>();
|
private final Map<String, PermissionAttachmentInfo> permissions = new HashMap<String, PermissionAttachmentInfo>();
|
||||||
private boolean dirtyPermissions = true;
|
|
||||||
|
|
||||||
public PermissibleBase(ServerOperator opable) {
|
public PermissibleBase(ServerOperator opable) {
|
||||||
this.opable = opable;
|
this.opable = opable;
|
||||||
@ -27,7 +26,7 @@ public class PermissibleBase implements Permissible {
|
|||||||
this.parent = (Permissible)opable;
|
this.parent = (Permissible)opable;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculatePermissions();
|
recalculatePermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOp() {
|
public boolean isOp() {
|
||||||
@ -51,8 +50,6 @@ public class PermissibleBase implements Permissible {
|
|||||||
throw new IllegalArgumentException("Permission name cannot be null");
|
throw new IllegalArgumentException("Permission name cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
calculatePermissions();
|
|
||||||
|
|
||||||
return permissions.containsKey(name.toLowerCase());
|
return permissions.containsKey(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,8 +66,6 @@ public class PermissibleBase implements Permissible {
|
|||||||
throw new IllegalArgumentException("Permission name cannot be null");
|
throw new IllegalArgumentException("Permission name cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
calculatePermissions();
|
|
||||||
|
|
||||||
String name = inName.toLowerCase();
|
String name = inName.toLowerCase();
|
||||||
|
|
||||||
if (isPermissionSet(name)) {
|
if (isPermissionSet(name)) {
|
||||||
@ -91,8 +86,6 @@ public class PermissibleBase implements Permissible {
|
|||||||
throw new IllegalArgumentException("Permission cannot be null");
|
throw new IllegalArgumentException("Permission cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
calculatePermissions();
|
|
||||||
|
|
||||||
String name = perm.getName().toLowerCase();
|
String name = perm.getName().toLowerCase();
|
||||||
|
|
||||||
if (isPermissionSet(name)) {
|
if (isPermissionSet(name)) {
|
||||||
@ -156,11 +149,6 @@ public class PermissibleBase implements Permissible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void recalculatePermissions() {
|
public void recalculatePermissions() {
|
||||||
dirtyPermissions = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void calculatePermissions() {
|
|
||||||
if (dirtyPermissions) {
|
|
||||||
clearPermissions();
|
clearPermissions();
|
||||||
Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp());
|
Set<Permission> defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp());
|
||||||
Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent);
|
Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent);
|
||||||
@ -175,9 +163,6 @@ public class PermissibleBase implements Permissible {
|
|||||||
for (PermissionAttachment attachment : attachments) {
|
for (PermissionAttachment attachment : attachments) {
|
||||||
calculateChildPermissions(attachment.getPermissions(), false, attachment);
|
calculateChildPermissions(attachment.getPermissions(), false, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
dirtyPermissions = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void clearPermissions() {
|
private synchronized void clearPermissions() {
|
||||||
@ -187,7 +172,8 @@ public class PermissibleBase implements Permissible {
|
|||||||
Bukkit.getServer().getPluginManager().unsubscribeFromPermission(name, parent);
|
Bukkit.getServer().getPluginManager().unsubscribeFromPermission(name, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager().unsubscribeFromDefaultPerms(isOp(), parent);
|
Bukkit.getServer().getPluginManager().unsubscribeFromDefaultPerms(false, parent);
|
||||||
|
Bukkit.getServer().getPluginManager().unsubscribeFromDefaultPerms(true, parent);
|
||||||
|
|
||||||
permissions.clear();
|
permissions.clear();
|
||||||
}
|
}
|
||||||
@ -246,7 +232,6 @@ public class PermissibleBase implements Permissible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||||
calculatePermissions();
|
|
||||||
return new HashSet<PermissionAttachmentInfo>(permissions.values());
|
return new HashSet<PermissionAttachmentInfo>(permissions.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user