Don't try to use old bPerms API if it is not available.

This commit is contained in:
KHobbits 2012-02-16 23:44:13 +00:00
parent b2dbb3f9e3
commit fab9688abb
2 changed files with 22 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.perm; package com.earth2me.essentials.perm;
import com.earth2me.essentials.Util;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -111,17 +112,6 @@ public class PermissionsHandler implements IPermissionsHandler
return; return;
} }
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
if (bPermPlugin != null && bPermPlugin.isEnabled())
{
if (!(handler instanceof BPermissionsHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions.");
handler = new BPermissionsHandler();
}
return;
}
final Plugin GMplugin = pluginManager.getPlugin("GroupManager"); final Plugin GMplugin = pluginManager.getPlugin("GroupManager");
if (GMplugin != null && GMplugin.isEnabled()) if (GMplugin != null && GMplugin.isEnabled())
{ {
@ -155,6 +145,26 @@ public class PermissionsHandler implements IPermissionsHandler
return; return;
} }
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
if (bPermPlugin != null && bPermPlugin.isEnabled())
{
final String bVer = bPermPlugin.getDescription().getVersion().replace(".", "");
if (Util.isInt(bVer) && Integer.parseInt(bVer) < 284)
{
if (!(handler instanceof BPermissionsHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions.");
handler = new BPermissionsHandler();
}
return;
}
if (!(handler instanceof SuperpermsHandler))
{
LOGGER.log(Level.INFO, "Essentials: bPermissions api broken, switching to superperms based permissions.");
handler = new SuperpermsHandler();
}
return;
}
final Plugin permPlugin = pluginManager.getPlugin("Permissions"); final Plugin permPlugin = pluginManager.getPlugin("Permissions");
if (permPlugin != null && permPlugin.isEnabled()) if (permPlugin != null && permPlugin.isEnabled())
{ {

View File

@ -27,7 +27,7 @@ public class SuperpermsHandler implements IPermissionsHandler
@Override @Override
public boolean inGroup(final Player base, final String group) public boolean inGroup(final Player base, final String group)
{ {
return false; return hasPermission(base, "group." + group);
} }
@Override @Override