summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXefir <xefir@crystalyx.net>2012-05-12 15:14:36 +0200
committerChris Ward <chris@chrisgward.com>2012-12-29 10:41:15 +1100
commit62832ad43a277dad1db0330395ea84a513aed54d (patch)
treece93e5f346618e69821063300e321bc2b91e2334
parent52b104aca5633166f5ac586292560401197920de (diff)
downloadEssentials-62832ad43a277dad1db0330395ea84a513aed54d.tar
Essentials-62832ad43a277dad1db0330395ea84a513aed54d.tar.gz
Essentials-62832ad43a277dad1db0330395ea84a513aed54d.tar.lz
Essentials-62832ad43a277dad1db0330395ea84a513aed54d.tar.xz
Essentials-62832ad43a277dad1db0330395ea84a513aed54d.zip
Added SimplyPerms Handler
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java11
-rw-r--r--Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java53
2 files changed, 64 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
index ab2332528..c5653b0ad 100644
--- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
+++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java
@@ -134,6 +134,17 @@ public class PermissionsHandler implements IPermissionsHandler
return;
}
+ final Plugin simplyPermsPlugin = pluginManager.getPlugin("SimplyPerms");
+ if (simplyPermsPlugin != null && simplyPermsPlugin.isEnabled())
+ {
+ if (!(handler instanceof SimplyPermsHandler))
+ {
+ LOGGER.log(Level.INFO, "Essentials: Using SimplyPerms based permissions.");
+ handler = new SimplyPermsHandler(simplyPermsPlugin);
+ }
+ return;
+ }
+
final Plugin privPlugin = pluginManager.getPlugin("Privileges");
if (privPlugin != null && privPlugin.isEnabled())
{
diff --git a/Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java b/Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java
new file mode 100644
index 000000000..cdd9ffa93
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/perm/SimplyPermsHandler.java
@@ -0,0 +1,53 @@
+package com.earth2me.essentials.perm;
+
+import java.util.List;
+
+import net.crystalyx.bukkit.simplyperms.SimplyAPI;
+import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
+
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+public class SimplyPermsHandler extends SuperpermsHandler {
+
+ private final transient SimplyAPI api;
+
+ public SimplyPermsHandler(final Plugin plugin) {
+ this.api = ((SimplyPlugin) plugin).getAPI();
+ }
+
+ @Override
+ public String getGroup(final Player base)
+ {
+ final List<String> groups = api.getPlayerGroups(base.getName());
+ if (groups == null || groups.isEmpty()) return null;
+ return groups.get(0);
+ }
+
+ @Override
+ public List<String> getGroups(final Player base)
+ {
+ return api.getPlayerGroups(base.getName());
+ }
+
+ @Override
+ public boolean inGroup(final Player base, final String group)
+ {
+ final List<String> groups = api.getPlayerGroups(base.getName());
+ for (String group1 : groups)
+ {
+ if (group1.equalsIgnoreCase(group))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean canBuild(Player base, String group)
+ {
+ return hasPermission(base, "essentials.build") || hasPermission(base, "permissions.allow.build");
+ }
+
+}