Minor cleanup of WEPIF constructors

This commit is contained in:
zml2008 2011-09-07 17:56:23 -07:00
parent 703131107d
commit 6b3f19f857
3 changed files with 21 additions and 6 deletions

View File

@ -58,6 +58,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
private Logger logger; private Logger logger;
protected boolean ignoreNijiPermsBridges; protected boolean ignoreNijiPermsBridges;
@Deprecated
public PermissionsResolverManager(Configuration config, Server server, String name, Logger logger) { public PermissionsResolverManager(Configuration config, Server server, String name, Logger logger) {
this.server = server; this.server = server;
this.name = name; this.name = name;
@ -65,6 +66,15 @@ public class PermissionsResolverManager implements PermissionsResolver {
loadConfig(new File("wepif.yml")); // TODO: config migration, maybe loadConfig(new File("wepif.yml")); // TODO: config migration, maybe
findResolver(); findResolver();
} }
public PermissionsResolverManager(Plugin plugin, String name, Logger logger) {
this.server = plugin.getServer();
this.name = name;
this.logger = logger;
new PermissionsResolverServerListener(this, plugin);
loadConfig(new File("wepif.yml")); // TODO: config migration, maybe
findResolver();
}
public void findResolver() { public void findResolver() {
if (tryPluginPermissionsResolver()) return; if (tryPluginPermissionsResolver()) return;
if (tryNijiPermissions()) return; if (tryNijiPermissions()) return;

View File

@ -29,10 +29,16 @@ import org.bukkit.plugin.Plugin;
public class PermissionsResolverServerListener extends ServerListener { public class PermissionsResolverServerListener extends ServerListener {
private PermissionsResolverManager manager; private PermissionsResolverManager manager;
@Deprecated
public PermissionsResolverServerListener(PermissionsResolverManager manager) { public PermissionsResolverServerListener(PermissionsResolverManager manager) {
this.manager = manager; this.manager = manager;
} }
public PermissionsResolverServerListener(PermissionsResolverManager manager, Plugin plugin) {
this.manager = manager;
register(plugin);
}
/** /**
* Called when a plugin is enabled * Called when a plugin is enabled
* *

View File

@ -87,8 +87,7 @@ public class WorldEditPlugin extends JavaPlugin {
// Set up configuration and such, including the permissions // Set up configuration and such, including the permissions
// resolver // resolver
config = new BukkitConfiguration(getConfiguration(), logger); config = new BukkitConfiguration(getConfiguration(), logger);
perms = new PermissionsResolverManager( perms = new PermissionsResolverManager(this, "WorldEdit", logger);
getConfiguration(), getServer(), "WorldEdit", logger);
// Load the configuration // Load the configuration
loadConfiguration(); loadConfiguration();
@ -138,13 +137,13 @@ public class WorldEditPlugin extends JavaPlugin {
new WorldEditCriticalPlayerListener(this); new WorldEditCriticalPlayerListener(this);
// The permissions resolver has some hooks of its own // The permissions resolver has some hooks of its own
(new PermissionsResolverServerListener(perms)).register(this); new PermissionsResolverServerListener(perms, this);
} }
/** /**
* Register an event. * Register an event.
* *
* @param type * @param typeName
* @param listener * @param listener
* @param priority * @param priority
*/ */
@ -160,7 +159,7 @@ public class WorldEditPlugin extends JavaPlugin {
/** /**
* Register an event at normal priority. * Register an event at normal priority.
* *
* @param type * @param typeName
* @param listener * @param listener
*/ */
public void registerEvent(String typeName, Listener listener) { public void registerEvent(String typeName, Listener listener) {