Add bPerm2 support for chat prefixes.

This commit is contained in:
KHobbits 2012-02-18 22:47:38 +00:00
parent 4f4d9f6209
commit 514f07ce57
4 changed files with 69 additions and 4 deletions

View File

@ -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

View File

@ -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");
}
}

View File

@ -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())

BIN
lib/bpermissions2.jar Normal file

Binary file not shown.