Updates to Plugin listener

This commit is contained in:
snowleo 2011-08-28 13:57:36 +02:00
parent 0c37e091c0
commit fa423b3dd2
3 changed files with 29 additions and 6 deletions

View File

@ -1,10 +1,12 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import com.earth2me.essentials.perm.BPermissionsHandler;
import com.earth2me.essentials.perm.ConfigPermissionsHandler; import com.earth2me.essentials.perm.ConfigPermissionsHandler;
import com.earth2me.essentials.perm.BukkitPermissionsHandler;
import com.earth2me.essentials.perm.Permissions3Handler; import com.earth2me.essentials.perm.Permissions3Handler;
import com.earth2me.essentials.perm.Permissions2Handler; import com.earth2me.essentials.perm.Permissions2Handler;
import com.earth2me.essentials.perm.PermissionsBukkitHandler;
import com.earth2me.essentials.perm.PermissionsExHandler; import com.earth2me.essentials.perm.PermissionsExHandler;
import com.earth2me.essentials.perm.SuperpermsHandler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginDisableEvent;
@ -58,10 +60,31 @@ public class EssentialsPluginListener extends ServerListener implements IConf
{ {
if (ess.getSettings().useBukkitPermissions()) if (ess.getSettings().useBukkitPermissions())
{ {
if (!(ess.getPermissionsHandler() instanceof BukkitPermissionsHandler)) final Plugin permissionsBukkitPlugin = pm.getPlugin("PermissionsBukkit");
final Plugin bPermissionsPlugin = pm.getPlugin("bPermissions");
if (permissionsBukkitPlugin != null && permissionsBukkitPlugin.isEnabled())
{ {
LOGGER.log(Level.INFO, "Essentials: Using superperms based permissions."); if (!(ess.getPermissionsHandler() instanceof PermissionsBukkitHandler))
ess.setPermissionsHandler(new BukkitPermissionsHandler()); {
LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
ess.setPermissionsHandler(new PermissionsBukkitHandler(permissionsBukkitPlugin));
}
}
else if (bPermissionsPlugin != null && bPermissionsPlugin.isEnabled())
{
if (!(ess.getPermissionsHandler() instanceof BPermissionsHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions.");
ess.setPermissionsHandler(new BPermissionsHandler());
}
}
else
{
if (!(ess.getPermissionsHandler() instanceof SuperpermsHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using superperms based permissions.");
ess.setPermissionsHandler(new SuperpermsHandler());
}
} }
} }
else else

View File

@ -10,7 +10,7 @@ public class Permissions2Handler implements IPermissionsHandler
{ {
private final transient PermissionHandler permissionHandler; private final transient PermissionHandler permissionHandler;
Permissions2Handler(final Plugin permissionsPlugin) public Permissions2Handler(final Plugin permissionsPlugin)
{ {
permissionHandler = ((Permissions)permissionsPlugin).getHandler(); permissionHandler = ((Permissions)permissionsPlugin).getHandler();
} }

View File

@ -10,7 +10,7 @@ public class Permissions3Handler implements IPermissionsHandler
{ {
private final transient PermissionHandler permissionHandler; private final transient PermissionHandler permissionHandler;
Permissions3Handler(final Plugin permissionsPlugin) public Permissions3Handler(final Plugin permissionsPlugin)
{ {
permissionHandler = ((Permissions)permissionsPlugin).getHandler(); permissionHandler = ((Permissions)permissionsPlugin).getHandler();
} }