Delay asking for PermissionHandler - might help PEX not freak out

This commit is contained in:
Mike Primm 2011-11-27 10:06:23 -06:00
parent 97f5d0c715
commit 48c43c5abb

View File

@ -12,11 +12,13 @@ import com.nijikokun.bukkit.Permissions.Permissions;
public class NijikokunPermissions implements PermissionProvider {
String name;
PermissionHandler permissions;
Plugin plugin;
public static NijikokunPermissions create(Server server, String name) {
Plugin permissionsPlugin = server.getPluginManager().getPlugin("Permissions");
if (permissionsPlugin == null)
return null;
server.getPluginManager().enablePlugin(permissionsPlugin);
Log.info("Using Permissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
return new NijikokunPermissions(permissionsPlugin, name);
@ -24,11 +26,13 @@ public class NijikokunPermissions implements PermissionProvider {
public NijikokunPermissions(Plugin permissionsPlugin, String name) {
this.name = name;
permissions = ((Permissions) permissionsPlugin).getHandler();
plugin = permissionsPlugin;
}
@Override
public boolean has(CommandSender sender, String permission) {
if(permissions == null)
permissions = ((Permissions)plugin).getHandler();
Player player = sender instanceof Player ? (Player) sender : null;
return player != null
? permissions.has(player, name + "." + permission) || permissions.has(player, name + ".*")