From c38a6b0677e543746813675f650a7a91de22ff39 Mon Sep 17 00:00:00 2001 From: zml2008 Date: Fri, 9 Sep 2011 15:10:25 -0700 Subject: [PATCH] Bug fixes --- .../sk89q/bukkit/migration/DinnerPermsResolver.java | 2 +- .../bukkit/migration/PermissionsResolverManager.java | 11 ++++++++++- .../migration/PermissionsResolverServerListener.java | 5 ++++- .../com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 3 --- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java index ffceea3af..f18ad0678 100644 --- a/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java +++ b/src/main/java/com/sk89q/bukkit/migration/DinnerPermsResolver.java @@ -53,7 +53,7 @@ public class DinnerPermsResolver implements PermissionsResolver { List groupNames = new ArrayList(); for (PermissionAttachmentInfo permAttach : player.getEffectivePermissions()) { String perm = permAttach.getPermission(); - if (!(perm.startsWith(GROUP_PREFIX) || permAttach.getValue())) + if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) continue; groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length())); } diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java index 731aed068..4c318daca 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverManager.java @@ -53,6 +53,7 @@ public class PermissionsResolverManager implements PermissionsResolver { private Server server; private PermissionsResolver perms; + private PermissionsResolverServerListener listener; private Configuration permsConfig; private String name; private Logger logger; @@ -72,7 +73,7 @@ public class PermissionsResolverManager implements PermissionsResolver { this.name = name; this.logger = logger; new PermissionsResolverServerListener(this, plugin); - loadConfig(new File("wepif.yml")); // TODO: config migration, maybe + loadConfig(new File("wepif.yml")); findResolver(); } public void findResolver() { @@ -205,6 +206,14 @@ public class PermissionsResolverManager implements PermissionsResolver { } return isUpdated; } + + boolean hasServerListener() { + return listener != null; + } + + void setServerListener(PermissionsResolverServerListener listener) { + this.listener = listener; + } public static class MissingPluginException extends Exception { private static final long serialVersionUID = 7044832912491608706L; diff --git a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java index cba3427de..40a532db6 100644 --- a/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java +++ b/src/main/java/com/sk89q/bukkit/migration/PermissionsResolverServerListener.java @@ -36,7 +36,9 @@ public class PermissionsResolverServerListener extends ServerListener { public PermissionsResolverServerListener(PermissionsResolverManager manager, Plugin plugin) { this.manager = manager; - register(plugin); + if (!manager.hasServerListener()) { + register(plugin); + } } /** @@ -82,5 +84,6 @@ public class PermissionsResolverServerListener extends ServerListener { this, Priority.Normal, plugin); plugin.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_DISABLE, this, Priority.Normal, plugin); + manager.setServerListener(this); } } diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 065b36989..06f26268e 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -135,9 +135,6 @@ public class WorldEditPlugin extends JavaPlugin { protected void registerEvents() { new WorldEditPlayerListener(this); new WorldEditCriticalPlayerListener(this); - - // The permissions resolver has some hooks of its own - new PermissionsResolverServerListener(perms, this); } /**