SPIGOT-3409: Improve performance of registering stupid amounts of permissions in plugin.yml

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2017-07-10 21:05:39 +10:00
parent 310ba479b7
commit 46c820e747

View File

@ -589,6 +589,11 @@ public final class SimplePluginManager implements PluginManager {
}
public void addPermission(Permission perm) {
addPermission(perm, true);
}
@Deprecated
public void addPermission(Permission perm, boolean dirty) {
String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
if (permissions.containsKey(name)) {
@ -596,7 +601,7 @@ public final class SimplePluginManager implements PluginManager {
}
permissions.put(name, perm);
calculatePermissionDefault(perm);
calculatePermissionDefault(perm, dirty);
}
public Set<Permission> getDefaultPermissions(boolean op) {
@ -616,21 +621,31 @@ public final class SimplePluginManager implements PluginManager {
defaultPerms.get(true).remove(perm);
defaultPerms.get(false).remove(perm);
calculatePermissionDefault(perm);
calculatePermissionDefault(perm, true);
}
}
private void calculatePermissionDefault(Permission perm) {
private void calculatePermissionDefault(Permission perm, boolean dirty) {
if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
defaultPerms.get(true).add(perm);
dirtyPermissibles(true);
if (dirty) {
dirtyPermissibles(true);
}
}
if ((perm.getDefault() == PermissionDefault.NOT_OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
defaultPerms.get(false).add(perm);
dirtyPermissibles(false);
if (dirty) {
dirtyPermissibles(false);
}
}
}
@Deprecated
public void dirtyPermissibles() {
dirtyPermissibles(true);
dirtyPermissibles(false);
}
private void dirtyPermissibles(boolean op) {
Set<Permissible> permissibles = getDefaultPermSubscriptions(op);