From 1511193e58c3f44b316999ec294cc1ec2faf0d9e Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 6 May 2021 12:23:09 +0100 Subject: [PATCH] Add Bukkit child permissions to the PermissionRegistry --- .../inject/server/LuckPermsPermissionMap.java | 8 +++++++ .../common/treeview/PermissionRegistry.java | 2 ++ .../inject/server/LuckPermsPermissionMap.java | 22 +++++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java index 7e1791bc6..bfd4f46cb 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java @@ -241,6 +241,10 @@ public final class LuckPermsPermissionMap extends ForwardingMap delegate) { this.delegate = delegate; + + for (String key : this.delegate.keySet()) { + LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key); + } } @Override @@ -251,6 +255,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap map) { super.putAll(map); + for (String key : map.keySet()) { + LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key); + } LuckPermsPermissionMap.this.update(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/treeview/PermissionRegistry.java b/common/src/main/java/me/lucko/luckperms/common/treeview/PermissionRegistry.java index c2248d93d..e02c14448 100644 --- a/common/src/main/java/me/lucko/luckperms/common/treeview/PermissionRegistry.java +++ b/common/src/main/java/me/lucko/luckperms/common/treeview/PermissionRegistry.java @@ -93,6 +93,8 @@ public class PermissionRegistry implements AutoCloseable { } private void doInsert(String permission) { + permission = permission.toLowerCase(); + // split the permission up into parts Iterable parts = DOT_SPLIT.split(permission); diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java index a0d7001e9..316158a3b 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java @@ -206,11 +206,11 @@ public final class LuckPermsPermissionMap extends ForwardingMap children = (Map) PERMISSION_CHILDREN_FIELD.get(permission); - while (children instanceof PermissionNotifyingChildrenMap) { - children = ((PermissionNotifyingChildrenMap) children).delegate; + while (children instanceof NotifyingChildrenMap) { + children = ((NotifyingChildrenMap) children).delegate; } - PermissionNotifyingChildrenMap notifyingChildren = new PermissionNotifyingChildrenMap(children); + NotifyingChildrenMap notifyingChildren = new NotifyingChildrenMap(children); PERMISSION_CHILDREN_FIELD.set(permission, notifyingChildren); } catch (Exception e) { e.printStackTrace(); @@ -226,8 +226,8 @@ public final class LuckPermsPermissionMap extends ForwardingMap children = (Map) PERMISSION_CHILDREN_FIELD.get(permission); - while (children instanceof PermissionNotifyingChildrenMap) { - children = ((PermissionNotifyingChildrenMap) children).delegate; + while (children instanceof NotifyingChildrenMap) { + children = ((NotifyingChildrenMap) children).delegate; } PERMISSION_CHILDREN_FIELD.set(permission, children); } catch (Exception e) { @@ -236,11 +236,15 @@ public final class LuckPermsPermissionMap extends ForwardingMap { + private final class NotifyingChildrenMap extends ForwardingMap { private final Map delegate; - PermissionNotifyingChildrenMap(Map delegate) { + NotifyingChildrenMap(Map delegate) { this.delegate = delegate; + + for (String key : this.delegate.keySet()) { + LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key); + } } @Override @@ -251,6 +255,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap map) { super.putAll(map); + for (String key : map.keySet()) { + LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key); + } LuckPermsPermissionMap.this.update(); }