From c8f6ea7f8e802ec063a9674d300fe520042696d0 Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 31 Aug 2011 13:02:21 +0200 Subject: [PATCH] Cleaner checkPermissions() --- .../essentials/perm/PermissionsHandler.java | 125 +++++++++--------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java index 2843b5d92..9fbf83f94 100644 --- a/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java +++ b/Essentials/src/com/earth2me/essentials/perm/PermissionsHandler.java @@ -101,74 +101,75 @@ public class PermissionsHandler implements IPermissionsHandler final PluginManager pluginManager = plugin.getServer().getPluginManager(); final Plugin permExPlugin = pluginManager.getPlugin("PermissionsEx"); - if (permExPlugin == null || !permExPlugin.isEnabled()) - { - final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit"); - final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions"); - final Plugin permPlugin = pluginManager.getPlugin("Permissions"); - - if (permBukkitPlugin != null && permBukkitPlugin.isEnabled()) - { - if (!(handler instanceof PermissionsBukkitHandler)) - { - LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions."); - handler = new PermissionsBukkitHandler(permBukkitPlugin); - } - } - else if (bPermPlugin != null && bPermPlugin.isEnabled()) - { - if (!(handler instanceof BPermissionsHandler)) - { - LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions."); - handler = new BPermissionsHandler(); - } - } - else if (permPlugin == null || !permPlugin.isEnabled()) - { - if (useSuperperms) - { - if (!(handler instanceof SuperpermsHandler)) - { - LOGGER.log(Level.INFO, "Essentials: Using superperms based permissions."); - handler = new SuperpermsHandler(); - } - } - else - { - if (!(handler instanceof ConfigPermissionsHandler)) - { - LOGGER.log(Level.INFO, "Essentials: Using config based permissions. Enable superperms in config."); - handler = new ConfigPermissionsHandler(plugin); - } - } - } - else - { - if (permPlugin.getDescription().getVersion().charAt(0) == '3') - { - if (!(handler instanceof Permissions3Handler)) - { - LOGGER.log(Level.INFO, "Essentials: Using Permissions 3 based permissions."); - handler = new Permissions3Handler(permPlugin); - } - } - else - { - if (!(handler instanceof Permissions2Handler)) - { - LOGGER.log(Level.INFO, "Essentials: Using Permissions 2 based permissions."); - handler = new Permissions2Handler(permPlugin); - } - } - } - } - else + if (permExPlugin != null && permExPlugin.isEnabled()) { if (!(handler instanceof PermissionsExHandler)) { LOGGER.log(Level.INFO, "Essentials: Using PermissionsEx based permissions."); handler = new PermissionsExHandler(); } + return; + } + + final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit"); + if (permBukkitPlugin != null && permBukkitPlugin.isEnabled()) + { + if (!(handler instanceof PermissionsBukkitHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions."); + handler = new PermissionsBukkitHandler(permBukkitPlugin); + } + 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 permPlugin = pluginManager.getPlugin("Permissions"); + if (permPlugin != null && permPlugin.isEnabled()) + { + if (permPlugin.getDescription().getVersion().charAt(0) == '3') + { + if (!(handler instanceof Permissions3Handler)) + { + LOGGER.log(Level.INFO, "Essentials: Using Permissions 3 based permissions."); + handler = new Permissions3Handler(permPlugin); + } + } + else + { + if (!(handler instanceof Permissions2Handler)) + { + LOGGER.log(Level.INFO, "Essentials: Using Permissions 2 based permissions."); + handler = new Permissions2Handler(permPlugin); + } + } + return; + } + + if (useSuperperms) + { + if (!(handler instanceof SuperpermsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using superperms based permissions."); + handler = new SuperpermsHandler(); + } + } + else + { + if (!(handler instanceof ConfigPermissionsHandler)) + { + LOGGER.log(Level.INFO, "Essentials: Using config based permissions. Enable superperms in config."); + handler = new ConfigPermissionsHandler(plugin); + } } }