summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect/src/com/earth2me
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsProtect/src/com/earth2me')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java b/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java
index 04b9d47df..0fedc33cf 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java
@@ -1,7 +1,10 @@
package com.earth2me.essentials.protect;
+import com.earth2me.essentials.Util;
import com.earth2me.essentials.api.IPermission;
import java.util.Locale;
+import org.bukkit.permissions.Permission;
+import org.bukkit.permissions.PermissionDefault;
public enum Permissions implements IPermission
@@ -12,10 +15,18 @@ public enum Permissions implements IPermission
;
private static final String base = "essentials.protect.";
private final String permission;
+ private final PermissionDefault defaultPerm;
+ private transient Permission bukkitPerm = null;
private Permissions()
{
+ this(PermissionDefault.OP);
+ }
+
+ private Permissions(final PermissionDefault defaultPerm)
+ {
permission = base + toString().toLowerCase(Locale.ENGLISH).replace('_', '.');
+ this.defaultPerm = defaultPerm;
}
@Override
@@ -23,4 +34,23 @@ public enum Permissions implements IPermission
{
return permission;
}
+
+ @Override
+ public Permission getBukkitPermission()
+ {
+ if (bukkitPerm != null)
+ {
+ return bukkitPerm;
+ }
+ else
+ {
+ return Util.registerPermission(getPermission(), getPermissionDefault());
+ }
+ }
+
+ @Override
+ public PermissionDefault getPermissionDefault()
+ {
+ return this.defaultPerm;
+ }
}