mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 21:29:47 +01:00
Add Bukkit child permissions to the PermissionRegistry
This commit is contained in:
parent
528d668bc6
commit
1511193e58
@ -241,6 +241,10 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
|
||||
NotifyingChildrenMap(Map<String, Boolean> 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<String, Permissi
|
||||
@Override
|
||||
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
||||
Boolean ret = super.put(key, value);
|
||||
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||
LuckPermsPermissionMap.this.update();
|
||||
return ret;
|
||||
}
|
||||
@ -258,6 +263,9 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
@Override
|
||||
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
||||
super.putAll(map);
|
||||
for (String key : map.keySet()) {
|
||||
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||
}
|
||||
LuckPermsPermissionMap.this.update();
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,8 @@ public class PermissionRegistry implements AutoCloseable {
|
||||
}
|
||||
|
||||
private void doInsert(String permission) {
|
||||
permission = permission.toLowerCase();
|
||||
|
||||
// split the permission up into parts
|
||||
Iterable<String> parts = DOT_SPLIT.split(permission);
|
||||
|
||||
|
@ -206,11 +206,11 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
try {
|
||||
//noinspection unchecked
|
||||
Map<String, Boolean> children = (Map<String, Boolean>) 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<String, Permissi
|
||||
try {
|
||||
//noinspection unchecked
|
||||
Map<String, Boolean> children = (Map<String, Boolean>) 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<String, Permissi
|
||||
return permission;
|
||||
}
|
||||
|
||||
private final class PermissionNotifyingChildrenMap extends ForwardingMap<String, Boolean> {
|
||||
private final class NotifyingChildrenMap extends ForwardingMap<String, Boolean> {
|
||||
private final Map<String, Boolean> delegate;
|
||||
|
||||
PermissionNotifyingChildrenMap(Map<String, Boolean> delegate) {
|
||||
NotifyingChildrenMap(Map<String, Boolean> 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<String, Permissi
|
||||
@Override
|
||||
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
||||
Boolean ret = super.put(key, value);
|
||||
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||
LuckPermsPermissionMap.this.update();
|
||||
return ret;
|
||||
}
|
||||
@ -258,6 +263,9 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
||||
@Override
|
||||
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
||||
super.putAll(map);
|
||||
for (String key : map.keySet()) {
|
||||
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||
}
|
||||
LuckPermsPermissionMap.this.update();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user