diff options
-rw-r--r-- | Essentials/nbproject/project.properties | 4 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java | 62 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java | 7 | ||||
-rw-r--r-- | lib/bpermissions2.jar | bin | 0 -> 129139 bytes |
4 files changed, 69 insertions, 4 deletions
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index 71fea5cf9..7a5ffe7bb 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -66,6 +66,7 @@ endorsed.classpath= excludes= file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar file.reference.bPermissions.jar=../lib/bPermissions.jar +file.reference.bpermissions2.jar=../lib/bpermissions2.jar file.reference.bukkit.jar=../lib/bukkit.jar file.reference.craftbukkit.jar=../lib/craftbukkit.jar file.reference.iCo4.jar=../lib/iCo4.jar @@ -97,7 +98,8 @@ javac.classpath=\ ${file.reference.bukkit.jar}:\ ${file.reference.craftbukkit.jar}:\ ${file.reference.Vault.jar}:\ - ${file.reference.Privileges.jar} + ${file.reference.Privileges.jar}:\ + ${file.reference.bpermissions2.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java b/Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java new file mode 100644 index 000000000..f4122bf53 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/perm/BPermissions2Handler.java @@ -0,0 +1,62 @@ +package com.earth2me.essentials.perm; + +import de.bananaco.bpermissions.api.ApiLayer; +import de.bananaco.bpermissions.api.World; +import de.bananaco.bpermissions.api.WorldManager; +import de.bananaco.bpermissions.api.util.Calculable; +import de.bananaco.bpermissions.api.util.CalculableType; +import java.util.Arrays; +import java.util.List; +import org.bukkit.entity.Player; + + +public class BPermissions2Handler extends SuperpermsHandler +{ + public BPermissions2Handler() + { + + } + + @Override + public String getGroup(final Player base) + { + final List<String> groups = getGroups(base); + if (groups == null || groups.isEmpty()) + { + return null; + } + return groups.get(0); + } + + @Override + public List<String> getGroups(final Player base) + { + final String[] groups = ApiLayer.getGroups(base.getWorld().getName(), CalculableType.USER, base.getName()); + return Arrays.asList(groups); + } + + @Override + public boolean inGroup(final Player base, final String group) + { + return ApiLayer.hasGroup(base.getWorld().getName(), CalculableType.USER, base.getName(), group); + } + + @Override + public boolean canBuild(final Player base, final String group) + { + return hasPermission(base, "essentials.build") || hasPermission(base, "bPermissions.build"); + } + + @Override + public String getPrefix(final Player base) + { + return ApiLayer.getValue(base.getWorld().getName(), CalculableType.USER, base.getName(), "prefix"); + } + + @Override + public String getSuffix(final Player base) + { + return ApiLayer.getValue(base.getWorld().getName(), CalculableType.USER, base.getName(), "suffix"); + } + +} diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java index 70a9e582c..a344968c2 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java @@ -158,12 +158,13 @@ public class PermissionsHandler implements IPermissionsHandler } return; } - if (!(handler instanceof SuperpermsHandler)) + if (!(handler instanceof BPermissions2Handler)) { - LOGGER.log(Level.INFO, "Essentials: bPermissions api broken, switching to superperms based permissions."); - handler = new SuperpermsHandler(); + LOGGER.log(Level.INFO, "Essentials: Using bPermissions2 based permissions."); + handler = new BPermissions2Handler(); } return; + } final Plugin permPlugin = pluginManager.getPlugin("Permissions"); if (permPlugin != null && permPlugin.isEnabled()) diff --git a/lib/bpermissions2.jar b/lib/bpermissions2.jar Binary files differnew file mode 100644 index 000000000..b6d344b82 --- /dev/null +++ b/lib/bpermissions2.jar |