Added multiworld permissions support to WEPIF

This commit is contained in:
Wizjany 2011-06-09 00:16:39 -04:00
parent 08c8a5ab23
commit c21357de28
9 changed files with 35 additions and 4 deletions

View File

@ -31,7 +31,7 @@
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>dummypermscompat</artifactId>
<version>1.1</version>
<version>1.2</version>
</dependency>
<!-- Bukkit -->

View File

@ -109,7 +109,12 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
return perms.contains("*") || perms.contains(permission);
}
public boolean hasPermission(String worldName, String player, String permission) {
return hasPermission(player, "worlds." + worldName + "." + permission)
|| hasPermission(player, permission);
}
public boolean inGroup(String player, String group) {
Set<String> groups = userGroups.get(player.toLowerCase());
if (groups == null) {

View File

@ -168,7 +168,12 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
return perms.contains("*") || perms.contains(permission);
}
public boolean hasPermission(String worldName, String player, String permission) {
return hasPermission(player, "worlds." + worldName + "." + permission)
|| hasPermission(player, permission);
}
public boolean inGroup(String player, String group) {
Set<String> groups = userGroups.get(player.toLowerCase());
if (groups == null) {

View File

@ -20,6 +20,7 @@
package com.sk89q.bukkit.migration;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@ -66,6 +67,15 @@ public class NijiPermissionsResolver implements PermissionsResolver {
}
}
public boolean hasPermission(String worldName, String name, String permission) {
try {
return api.getHandler().has(worldName, name, permission);
} catch (Throwable t) {
t.printStackTrace();
return false;
}
}
@SuppressWarnings({ "static-access" })
public boolean inGroup(String name, String group) {
try {

View File

@ -21,6 +21,7 @@ package com.sk89q.bukkit.migration;
public interface PermissionsProvider {
public boolean hasPermission(String name, String permission);
public boolean hasPermission(String worldName, String name, String permission);
public boolean inGroup(String player, String group);
public String[] getGroups(String player);
}

View File

@ -22,6 +22,7 @@ package com.sk89q.bukkit.migration;
public interface PermissionsResolver {
public void load();
public boolean hasPermission(String name, String permission);
public boolean hasPermission(String worldName, String name, String permission);
public boolean inGroup(String player, String group);
public String[] getGroups(String player);
}

View File

@ -102,6 +102,10 @@ public class PermissionsResolverManager implements PermissionsResolver {
return perms.hasPermission(name, permission);
}
public boolean hasPermission(String worldName, String name, String permission) {
return perms.hasPermission(worldName, name, permission);
}
public boolean inGroup(String player, String group) {
return perms.inGroup(player, group);
}

View File

@ -34,6 +34,10 @@ public class PluginPermissionsResolver implements PermissionsResolver {
return resolver.hasPermission(name, permission);
}
public boolean hasPermission(String worldName, String name, String permission) {
return resolver.hasPermission(worldName, name, permission);
}
public boolean inGroup(String player, String group) {
return resolver.inGroup(player, group);
}

View File

@ -109,7 +109,8 @@ public class BukkitPlayer extends LocalPlayer {
@Override
public boolean hasPermission(String perm) {
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|| plugin.getPermissionsResolver().hasPermission(player.getName(), perm);
|| plugin.getPermissionsResolver().hasPermission(
player.getWorld().getName(), player.getName(), perm);
}
@Override