diff --git a/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java b/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java index d0fd41a0dd..75b77cc4fe 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java +++ b/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java @@ -73,8 +73,11 @@ public class PermissibleBase implements Permissible { String name = inName.toLowerCase(Locale.ROOT); - if (isPermissionSet(name)) { - return permissions.get(name).getValue(); + // Paper start + PermissionAttachmentInfo info = permissions.get(name); + if (info != null) { + return info.getValue(); + // Paper end } else { Permission perm = Bukkit.getServer().getPluginManager().getPermission(name); @@ -94,15 +97,18 @@ public class PermissibleBase implements Permissible { String name = perm.getName().toLowerCase(Locale.ROOT); - if (isPermissionSet(name)) { - return permissions.get(name).getValue(); + // Paper start + PermissionAttachmentInfo info = permissions.get(name); + if (info != null) { + return info.getValue(); } + // Paper end return perm.getDefault().getValue(isOp()); } @Override @NotNull - public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { + public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) { // Paper - synchronized if (name == null) { throw new IllegalArgumentException("Permission name cannot be null"); } else if (plugin == null) { @@ -121,7 +127,7 @@ public class PermissibleBase implements Permissible { @Override @NotNull - public PermissionAttachment addAttachment(@NotNull Plugin plugin) { + public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin) { // Paper - synchronized if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } else if (!plugin.isEnabled()) { @@ -137,7 +143,7 @@ public class PermissibleBase implements Permissible { } @Override - public void removeAttachment(@NotNull PermissionAttachment attachment) { + public synchronized void removeAttachment(@NotNull PermissionAttachment attachment) { // Paper - synchronized if (attachment == null) { throw new IllegalArgumentException("Attachment cannot be null"); } @@ -156,7 +162,7 @@ public class PermissibleBase implements Permissible { } @Override - public void recalculatePermissions() { + public synchronized void recalculatePermissions() { // Paper - synchronized clearPermissions(); Set defaults = Bukkit.getServer().getPluginManager().getDefaultPermissions(isOp()); Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent); @@ -205,7 +211,7 @@ public class PermissibleBase implements Permissible { @Override @Nullable - public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { + public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) { // Paper if (name == null) { throw new IllegalArgumentException("Permission name cannot be null"); } else if (plugin == null) { @@ -225,7 +231,7 @@ public class PermissibleBase implements Permissible { @Override @Nullable - public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { + public synchronized PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) { // Paper - synchronized if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); } else if (!plugin.isEnabled()) { @@ -245,7 +251,7 @@ public class PermissibleBase implements Permissible { @Override @NotNull - public Set getEffectivePermissions() { + public synchronized Set getEffectivePermissions() { // Paper - synchronized return new HashSet(permissions.values()); }