mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-08 16:12:18 -07:00
#674: Optimize and cleanup PermissibleBase
By: JDIALIA <jdialia@gmail.com>
This commit is contained in:
@@ -16,17 +16,14 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* Base Permissible for use in any Permissible object via proxy or extension
|
* Base Permissible for use in any Permissible object via proxy or extension
|
||||||
*/
|
*/
|
||||||
public class PermissibleBase implements Permissible {
|
public class PermissibleBase implements Permissible {
|
||||||
private ServerOperator opable;
|
private final ServerOperator opable;
|
||||||
private Permissible parent = this;
|
private final Permissible parent;
|
||||||
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>();
|
||||||
|
|
||||||
public PermissibleBase(@Nullable ServerOperator opable) {
|
public PermissibleBase(@Nullable ServerOperator opable) {
|
||||||
this.opable = opable;
|
this.opable = opable;
|
||||||
|
this.parent = (opable instanceof Permissible) ? (Permissible) opable : this;
|
||||||
if (opable instanceof Permissible) {
|
|
||||||
this.parent = (Permissible) opable;
|
|
||||||
}
|
|
||||||
|
|
||||||
recalculatePermissions();
|
recalculatePermissions();
|
||||||
}
|
}
|
||||||
@@ -144,8 +141,7 @@ public class PermissibleBase implements Permissible {
|
|||||||
throw new IllegalArgumentException("Attachment cannot be null");
|
throw new IllegalArgumentException("Attachment cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachments.contains(attachment)) {
|
if (attachments.remove(attachment)) {
|
||||||
attachments.remove(attachment);
|
|
||||||
PermissionRemovedExecutor ex = attachment.getRemovalCallback();
|
PermissionRemovedExecutor ex = attachment.getRemovalCallback();
|
||||||
|
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
@@ -253,7 +249,7 @@ public class PermissibleBase implements Permissible {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class RemoveAttachmentRunnable implements Runnable {
|
private static class RemoveAttachmentRunnable implements Runnable {
|
||||||
private PermissionAttachment attachment;
|
private final PermissionAttachment attachment;
|
||||||
|
|
||||||
public RemoveAttachmentRunnable(@NotNull PermissionAttachment attachment) {
|
public RemoveAttachmentRunnable(@NotNull PermissionAttachment attachment) {
|
||||||
this.attachment = attachment;
|
this.attachment = attachment;
|
||||||
|
Reference in New Issue
Block a user