summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Wardian <krinsdeath@hotmail.com>2012-02-10 15:54:19 -0800
committerJeff Wardian <krinsdeath@hotmail.com>2012-02-11 10:06:18 -0800
commitc890ea8f87b2d798cfe4b1bbefdc8b62fd227592 (patch)
tree6ee240c8be9534a80086a7b3227104540a8c58e7
parentf0ee026fb97ac69822cd3f2f74b5e088ba7b3b66 (diff)
downloadEssentials-c890ea8f87b2d798cfe4b1bbefdc8b62fd227592.tar
Essentials-c890ea8f87b2d798cfe4b1bbefdc8b62fd227592.tar.gz
Essentials-c890ea8f87b2d798cfe4b1bbefdc8b62fd227592.tar.lz
Essentials-c890ea8f87b2d798cfe4b1bbefdc8b62fd227592.tar.xz
Essentials-c890ea8f87b2d798cfe4b1bbefdc8b62fd227592.zip
Added PrivilegesHandler.java;
Implemented privileges in PermissionsHandler.java; Fixed PrivilegesHandler.canBuild();
-rw-r--r--Essentials/nbproject/project.properties4
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java11
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/PrivilegesHandler.java61
-rw-r--r--lib/Privileges.jarbin0 -> 101774 bytes
4 files changed, 75 insertions, 1 deletions
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties
index 4e80ceafa..71fea5cf9 100644
--- a/Essentials/nbproject/project.properties
+++ b/Essentials/nbproject/project.properties
@@ -76,6 +76,7 @@ file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
file.reference.Permissions3.jar=../lib/Permissions3.jar
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
+file.reference.Privileges.jar=..\\lib\\Privileges.jar
file.reference.Vault.jar=../lib/Vault.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
@@ -95,7 +96,8 @@ javac.classpath=\
${reference.EssentialsGroupManager.jar}:\
${file.reference.bukkit.jar}:\
${file.reference.craftbukkit.jar}:\
- ${file.reference.Vault.jar}
+ ${file.reference.Vault.jar}:\
+ ${file.reference.Privileges.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
index 8c16aab7a..aa786934e 100644
--- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
+++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
@@ -144,6 +144,17 @@ public class PermissionsHandler implements IPermissionsHandler
return;
}
+ final Plugin privPlugin = pluginManager.getPlugin("Privileges");
+ if (privPlugin != null && privPlugin.isEnabled())
+ {
+ if (!(handler instanceof PrivilegesHandler))
+ {
+ LOGGER.log(Level.INFO, "Essentials: Using Privileges based permissions.");
+ handler = new PrivilegesHandler(privPlugin);
+ }
+ return;
+ }
+
final Plugin permPlugin = pluginManager.getPlugin("Permissions");
if (permPlugin != null && permPlugin.isEnabled())
{
diff --git a/Essentials/src/com/earth2me/essentials/perm/PrivilegesHandler.java b/Essentials/src/com/earth2me/essentials/perm/PrivilegesHandler.java
new file mode 100644
index 000000000..c81f93cbc
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/perm/PrivilegesHandler.java
@@ -0,0 +1,61 @@
+package com.earth2me.essentials.perm;
+
+import java.util.ArrayList;
+import java.util.List;
+import net.krinsoft.privileges.Privileges;
+import net.krinsoft.privileges.groups.Group;
+import net.krinsoft.privileges.groups.GroupManager;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class PrivilegesHandler extends SuperpermsHandler
+{
+ private final transient Privileges plugin;
+ private final GroupManager manager;
+
+ public PrivilegesHandler(final Plugin plugin)
+ {
+ this.plugin = (Privileges) plugin;
+ this.manager = this.plugin.getGroupManager();
+ }
+
+ @Override
+ public String getGroup(final Player base)
+ {
+ Group group = manager.getGroup(base);
+ if (group == null)
+ {
+ return null;
+ }
+ return group.getName();
+ }
+
+ @Override
+ public List<String> getGroups(final Player base)
+ {
+ Group group = manager.getGroup(base);
+ if (group == null)
+ {
+ return new ArrayList<String>();
+ }
+ return group.getGroupTree();
+ }
+
+ @Override
+ public boolean inGroup(final Player base, final String group)
+ {
+ Group pGroup = manager.getGroup(base);
+ if (pGroup == null)
+ {
+ return false;
+ }
+ return pGroup.isMemberOf(group);
+ }
+
+ @Override
+ public boolean canBuild(Player base, String group)
+ {
+ return base.hasPermission("essentials.build") || base.hasPermission("privileges.build");
+ }
+
+}
diff --git a/lib/Privileges.jar b/lib/Privileges.jar
new file mode 100644
index 000000000..e9dd1d04d
--- /dev/null
+++ b/lib/Privileges.jar
Binary files differ