mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-25 01:25:03 +01:00
[Bleeding] Lazily calculate permissions. Addresses BUKKIT-1122
By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
parent
a9dd81a309
commit
1cbbdebfe3
1 changed files with 13 additions and 12 deletions
|
@ -34,6 +34,7 @@ public final class PluginDescriptionFile {
|
||||||
private boolean database = false;
|
private boolean database = false;
|
||||||
private PluginLoadOrder order = PluginLoadOrder.POSTWORLD;
|
private PluginLoadOrder order = PluginLoadOrder.POSTWORLD;
|
||||||
private List<Permission> permissions = null;
|
private List<Permission> permissions = null;
|
||||||
|
private Map<?, ?> lazyPermissions = null;
|
||||||
private PermissionDefault defaultPerm = PermissionDefault.OP;
|
private PermissionDefault defaultPerm = PermissionDefault.OP;
|
||||||
|
|
||||||
public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException {
|
public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException {
|
||||||
|
@ -150,6 +151,14 @@ public final class PluginDescriptionFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Permission> getPermissions() {
|
public List<Permission> getPermissions() {
|
||||||
|
if (permissions == null) {
|
||||||
|
if (lazyPermissions == null) {
|
||||||
|
permissions = ImmutableList.<Permission>of();
|
||||||
|
} else {
|
||||||
|
permissions = ImmutableList.copyOf(Permission.loadPermissions(lazyPermissions, "Permission node '%s' in plugin description file for " + getFullName() + " is invalid", defaultPerm));
|
||||||
|
lazyPermissions = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
return permissions;
|
return permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,18 +324,10 @@ public final class PluginDescriptionFile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.get("permissions") != null) {
|
try {
|
||||||
try {
|
lazyPermissions = (Map<?, ?>) map.get("permissions");
|
||||||
Map<?, ?> perms = (Map<?, ?>) map.get("permissions");
|
} catch (ClassCastException ex) {
|
||||||
|
throw new InvalidDescriptionException(ex, "permissions are of the wrong type");
|
||||||
permissions = ImmutableList.copyOf(Permission.loadPermissions(perms, "Permission node '%s' in plugin description file for " + getFullName() + " is invalid", defaultPerm));
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
throw new InvalidDescriptionException(ex, "permissions are of wrong type");
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
throw new InvalidDescriptionException(ex, "permissions are not properly defined");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
permissions = ImmutableList.<Permission>of();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map.get("prefix") != null) {
|
if (map.get("prefix") != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue