summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-01-03 01:53:38 +0100
committersnowleo <schneeleo@gmail.com>2012-01-03 01:53:38 +0100
commit869d79ae73e30a034c2c406d84ce41bcd7c2d67a (patch)
treeffba0b0acd36a196501e2b4a92ab8d9e07217b63 /EssentialsProtect
parent7153676137a23f6780b21682456377b0f86b6fb1 (diff)
downloadEssentials-869d79ae73e30a034c2c406d84ce41bcd7c2d67a.tar
Essentials-869d79ae73e30a034c2c406d84ce41bcd7c2d67a.tar.gz
Essentials-869d79ae73e30a034c2c406d84ce41bcd7c2d67a.tar.lz
Essentials-869d79ae73e30a034c2c406d84ce41bcd7c2d67a.tar.xz
Essentials-869d79ae73e30a034c2c406d84ce41bcd7c2d67a.zip
This feels so good D:
Diffstat (limited to 'EssentialsProtect')
-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;
+ }
}