Cleaner checkPermissions()

This commit is contained in:
snowleo 2011-08-31 13:02:21 +02:00
parent d3dd4980a4
commit c8f6ea7f8e

View File

@ -101,12 +101,17 @@ public class PermissionsHandler implements IPermissionsHandler
final PluginManager pluginManager = plugin.getServer().getPluginManager(); final PluginManager pluginManager = plugin.getServer().getPluginManager();
final Plugin permExPlugin = pluginManager.getPlugin("PermissionsEx"); final Plugin permExPlugin = pluginManager.getPlugin("PermissionsEx");
if (permExPlugin == null || !permExPlugin.isEnabled()) if (permExPlugin != null && permExPlugin.isEnabled())
{ {
final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit"); if (!(handler instanceof PermissionsExHandler))
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions"); {
final Plugin permPlugin = pluginManager.getPlugin("Permissions"); 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 (permBukkitPlugin != null && permBukkitPlugin.isEnabled())
{ {
if (!(handler instanceof PermissionsBukkitHandler)) if (!(handler instanceof PermissionsBukkitHandler))
@ -114,35 +119,22 @@ public class PermissionsHandler implements IPermissionsHandler
LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions."); LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
handler = new PermissionsBukkitHandler(permBukkitPlugin); handler = new PermissionsBukkitHandler(permBukkitPlugin);
} }
return;
} }
else if (bPermPlugin != null && bPermPlugin.isEnabled())
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
if (bPermPlugin != null && bPermPlugin.isEnabled())
{ {
if (!(handler instanceof BPermissionsHandler)) if (!(handler instanceof BPermissionsHandler))
{ {
LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions."); LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions.");
handler = new BPermissionsHandler(); handler = new BPermissionsHandler();
} }
return;
} }
else if (permPlugin == null || !permPlugin.isEnabled())
{ final Plugin permPlugin = pluginManager.getPlugin("Permissions");
if (useSuperperms) if (permPlugin != null && permPlugin.isEnabled())
{
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 (permPlugin.getDescription().getVersion().charAt(0) == '3')
{ {
@ -160,14 +152,23 @@ public class PermissionsHandler implements IPermissionsHandler
handler = new Permissions2Handler(permPlugin); handler = new Permissions2Handler(permPlugin);
} }
} }
return;
}
if (useSuperperms)
{
if (!(handler instanceof SuperpermsHandler))
{
LOGGER.log(Level.INFO, "Essentials: Using superperms based permissions.");
handler = new SuperpermsHandler();
} }
} }
else else
{ {
if (!(handler instanceof PermissionsExHandler)) if (!(handler instanceof ConfigPermissionsHandler))
{ {
LOGGER.log(Level.INFO, "Essentials: Using PermissionsEx based permissions."); LOGGER.log(Level.INFO, "Essentials: Using config based permissions. Enable superperms in config.");
handler = new PermissionsExHandler(); handler = new ConfigPermissionsHandler(plugin);
} }
} }
} }