summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-03-10 15:05:59 -0600
committerEvilSeph <evilseph@gmail.com>2012-03-15 06:46:02 -0400
commit2e01621c63cf2a62a238093f2b69ff759d59200c (patch)
treed67b7291ea1f078577e76bfab66ed9ba31293eeb
parent23c519acb78af54e60222dc58ea7badbde24ece9 (diff)
downloadbukkit-2e01621c63cf2a62a238093f2b69ff759d59200c.tar
bukkit-2e01621c63cf2a62a238093f2b69ff759d59200c.tar.gz
bukkit-2e01621c63cf2a62a238093f2b69ff759d59200c.tar.lz
bukkit-2e01621c63cf2a62a238093f2b69ff759d59200c.tar.xz
bukkit-2e01621c63cf2a62a238093f2b69ff759d59200c.zip
[Bleeding] Lazily calculate permissions. Addresses BUKKIT-1122
-rw-r--r--src/main/java/org/bukkit/plugin/PluginDescriptionFile.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
index 1b68db46..21858eb5 100644
--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
+++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
@@ -34,6 +34,7 @@ public final class PluginDescriptionFile {
private boolean database = false;
private PluginLoadOrder order = PluginLoadOrder.POSTWORLD;
private List<Permission> permissions = null;
+ private Map<?, ?> lazyPermissions = null;
private PermissionDefault defaultPerm = PermissionDefault.OP;
public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException {
@@ -150,6 +151,14 @@ public final class PluginDescriptionFile {
}
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;
}
@@ -315,18 +324,10 @@ public final class PluginDescriptionFile {
}
}
- if (map.get("permissions") != null) {
- try {
- Map<?, ?> perms = (Map<?, ?>) map.get("permissions");
-
- 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();
+ try {
+ lazyPermissions = (Map<?, ?>) map.get("permissions");
+ } catch (ClassCastException ex) {
+ throw new InvalidDescriptionException(ex, "permissions are of the wrong type");
}
if (map.get("prefix") != null) {