From fa423b3dd22d558885a3e25b6ea187e1b5e5eef2 Mon Sep 17 00:00:00 2001 From: snowleo Date: Sun, 28 Aug 2011 13:57:36 +0200 Subject: [PATCH] Updates to Plugin listener --- .../essentials/EssentialsPluginListener.java | 31 ++++++++++++++++--- .../essentials/perm/Permissions2Handler.java | 2 +- .../essentials/perm/Permissions3Handler.java | 2 +- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java index 2155ca622..6d895082f 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java @@ -1,10 +1,12 @@ package com.earth2me.essentials; +import com.earth2me.essentials.perm.BPermissionsHandler; import com.earth2me.essentials.perm.ConfigPermissionsHandler; -import com.earth2me.essentials.perm.BukkitPermissionsHandler; import com.earth2me.essentials.perm.Permissions3Handler; import com.earth2me.essentials.perm.Permissions2Handler; +import com.earth2me.essentials.perm.PermissionsBukkitHandler; import com.earth2me.essentials.perm.PermissionsExHandler; +import com.earth2me.essentials.perm.SuperpermsHandler; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.event.server.PluginDisableEvent; @@ -58,10 +60,31 @@ public class EssentialsPluginListener extends ServerListener implements IConf { 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."); - ess.setPermissionsHandler(new BukkitPermissionsHandler()); + if (!(ess.getPermissionsHandler() instanceof PermissionsBukkitHandler)) + { + 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 diff --git a/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java b/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java index eca6feaf8..d22eb1c3a 100644 --- a/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java +++ b/Essentials/src/com/earth2me/essentials/perm/Permissions2Handler.java @@ -10,7 +10,7 @@ public class Permissions2Handler implements IPermissionsHandler { private final transient PermissionHandler permissionHandler; - Permissions2Handler(final Plugin permissionsPlugin) + public Permissions2Handler(final Plugin permissionsPlugin) { permissionHandler = ((Permissions)permissionsPlugin).getHandler(); } diff --git a/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java b/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java index 905b5e0a9..84318689e 100644 --- a/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java +++ b/Essentials/src/com/earth2me/essentials/perm/Permissions3Handler.java @@ -10,7 +10,7 @@ public class Permissions3Handler implements IPermissionsHandler { private final transient PermissionHandler permissionHandler; - Permissions3Handler(final Plugin permissionsPlugin) + public Permissions3Handler(final Plugin permissionsPlugin) { permissionHandler = ((Permissions)permissionsPlugin).getHandler(); }