Merge pull request #46 from krinsdeath/master

Added Privileges to known Permissions plugins
This commit is contained in:
KHobbits 2012-02-11 12:12:59 -08:00
commit bbc6da5106
4 changed files with 75 additions and 1 deletions

View File

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

View File

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

View File

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

BIN
lib/Privileges.jar Normal file

Binary file not shown.