Added multiworld permissions support to WEPIF

Dieser Commit ist enthalten in:
Wizjany 2011-06-09 00:16:39 -04:00
Ursprung 08c8a5ab23
Commit c21357de28
9 geänderte Dateien mit 35 neuen und 4 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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