From e3ed32721a2af97e08b6b31601defc0c5535c260 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 16 Nov 2021 07:27:40 +1100 Subject: [PATCH] #674: Optimize and cleanup PermissibleBase By: JDIALIA --- .../org/bukkit/permissions/PermissibleBase.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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 497775f7f8..728fc46daf 100644 --- a/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java +++ b/paper-api/src/main/java/org/bukkit/permissions/PermissibleBase.java @@ -16,17 +16,14 @@ import org.jetbrains.annotations.Nullable; * Base Permissible for use in any Permissible object via proxy or extension */ public class PermissibleBase implements Permissible { - private ServerOperator opable; - private Permissible parent = this; + private final ServerOperator opable; + private final Permissible parent; private final List attachments = new LinkedList(); private final Map permissions = new HashMap(); public PermissibleBase(@Nullable ServerOperator opable) { this.opable = opable; - - if (opable instanceof Permissible) { - this.parent = (Permissible) opable; - } + this.parent = (opable instanceof Permissible) ? (Permissible) opable : this; recalculatePermissions(); } @@ -144,8 +141,7 @@ public class PermissibleBase implements Permissible { throw new IllegalArgumentException("Attachment cannot be null"); } - if (attachments.contains(attachment)) { - attachments.remove(attachment); + if (attachments.remove(attachment)) { PermissionRemovedExecutor ex = attachment.getRemovalCallback(); if (ex != null) { @@ -253,7 +249,7 @@ public class PermissibleBase implements Permissible { } private static class RemoveAttachmentRunnable implements Runnable { - private PermissionAttachment attachment; + private final PermissionAttachment attachment; public RemoveAttachmentRunnable(@NotNull PermissionAttachment attachment) { this.attachment = attachment;