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) {
|
NotifyingChildrenMap(Map<String, Boolean> delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
|
||||||
|
for (String key : this.delegate.keySet()) {
|
||||||
|
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -251,6 +255,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
|||||||
@Override
|
@Override
|
||||||
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
||||||
Boolean ret = super.put(key, value);
|
Boolean ret = super.put(key, value);
|
||||||
|
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||||
LuckPermsPermissionMap.this.update();
|
LuckPermsPermissionMap.this.update();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -258,6 +263,9 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
|||||||
@Override
|
@Override
|
||||||
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
||||||
super.putAll(map);
|
super.putAll(map);
|
||||||
|
for (String key : map.keySet()) {
|
||||||
|
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||||
|
}
|
||||||
LuckPermsPermissionMap.this.update();
|
LuckPermsPermissionMap.this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +93,8 @@ public class PermissionRegistry implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doInsert(String permission) {
|
private void doInsert(String permission) {
|
||||||
|
permission = permission.toLowerCase();
|
||||||
|
|
||||||
// split the permission up into parts
|
// split the permission up into parts
|
||||||
Iterable<String> parts = DOT_SPLIT.split(permission);
|
Iterable<String> parts = DOT_SPLIT.split(permission);
|
||||||
|
|
||||||
|
@ -206,11 +206,11 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
|||||||
try {
|
try {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
||||||
while (children instanceof PermissionNotifyingChildrenMap) {
|
while (children instanceof NotifyingChildrenMap) {
|
||||||
children = ((PermissionNotifyingChildrenMap) children).delegate;
|
children = ((NotifyingChildrenMap) children).delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionNotifyingChildrenMap notifyingChildren = new PermissionNotifyingChildrenMap(children);
|
NotifyingChildrenMap notifyingChildren = new NotifyingChildrenMap(children);
|
||||||
PERMISSION_CHILDREN_FIELD.set(permission, notifyingChildren);
|
PERMISSION_CHILDREN_FIELD.set(permission, notifyingChildren);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -226,8 +226,8 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
|||||||
try {
|
try {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
Map<String, Boolean> children = (Map<String, Boolean>) PERMISSION_CHILDREN_FIELD.get(permission);
|
||||||
while (children instanceof PermissionNotifyingChildrenMap) {
|
while (children instanceof NotifyingChildrenMap) {
|
||||||
children = ((PermissionNotifyingChildrenMap) children).delegate;
|
children = ((NotifyingChildrenMap) children).delegate;
|
||||||
}
|
}
|
||||||
PERMISSION_CHILDREN_FIELD.set(permission, children);
|
PERMISSION_CHILDREN_FIELD.set(permission, children);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -236,11 +236,15 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
|||||||
return permission;
|
return permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class PermissionNotifyingChildrenMap extends ForwardingMap<String, Boolean> {
|
private final class NotifyingChildrenMap extends ForwardingMap<String, Boolean> {
|
||||||
private final Map<String, Boolean> delegate;
|
private final Map<String, Boolean> delegate;
|
||||||
|
|
||||||
PermissionNotifyingChildrenMap(Map<String, Boolean> delegate) {
|
NotifyingChildrenMap(Map<String, Boolean> delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
|
||||||
|
for (String key : this.delegate.keySet()) {
|
||||||
|
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -251,6 +255,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
|||||||
@Override
|
@Override
|
||||||
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
public Boolean put(@NonNull String key, @NonNull Boolean value) {
|
||||||
Boolean ret = super.put(key, value);
|
Boolean ret = super.put(key, value);
|
||||||
|
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||||
LuckPermsPermissionMap.this.update();
|
LuckPermsPermissionMap.this.update();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -258,6 +263,9 @@ public final class LuckPermsPermissionMap extends ForwardingMap<String, Permissi
|
|||||||
@Override
|
@Override
|
||||||
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
public void putAll(@NonNull Map<? extends String, ? extends Boolean> map) {
|
||||||
super.putAll(map);
|
super.putAll(map);
|
||||||
|
for (String key : map.keySet()) {
|
||||||
|
LuckPermsPermissionMap.this.plugin.getPermissionRegistry().insert(key);
|
||||||
|
}
|
||||||
LuckPermsPermissionMap.this.update();
|
LuckPermsPermissionMap.this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user