mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fixed default permissions with the built-in permission resolvers.
This commit is contained in:
parent
01fa16aa54
commit
ecb2942f1d
@ -29,6 +29,7 @@ import org.bukkit.util.config.Configuration;
|
||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
private Configuration config;
|
||||
private Map<String,Set<String>> userPermissionsCache;
|
||||
private Set<String> defaultPermissionsCache;
|
||||
private Map<String,Set<String>> userGroups;
|
||||
|
||||
public ConfigurationPermissionsResolver(Configuration config) {
|
||||
@ -38,6 +39,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
public void load() {
|
||||
userGroups = new HashMap<String,Set<String>>();
|
||||
userPermissionsCache = new HashMap<String,Set<String>>();
|
||||
defaultPermissionsCache = new HashSet<String>();
|
||||
|
||||
Map<String,Set<String>> userGroupPermissions = new HashMap<String,Set<String>>();
|
||||
|
||||
@ -51,6 +53,10 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
if (permissions.size() > 0) {
|
||||
Set<String> groupPerms = new HashSet<String>(permissions);
|
||||
userGroupPermissions.put(key, groupPerms);
|
||||
|
||||
if (key.equals("default")) {
|
||||
defaultPermissionsCache.addAll(permissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -90,7 +96,8 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||
public boolean hasPermission(String player, String permission) {
|
||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
||||
if (perms == null) {
|
||||
return false;
|
||||
return defaultPermissionsCache.contains(permission)
|
||||
|| defaultPermissionsCache.contains("*");
|
||||
}
|
||||
|
||||
return perms.contains("*") || perms.contains(permission);
|
||||
|
@ -31,6 +31,7 @@ import java.util.HashMap;
|
||||
|
||||
public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
private Map<String,Set<String>> userPermissionsCache;
|
||||
private Set<String> defaultPermissionsCache;
|
||||
private Map<String,Set<String>> userGroups;
|
||||
|
||||
public FlatFilePermissionsResolver() {
|
||||
@ -90,8 +91,13 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
public void load() {
|
||||
userGroups = new HashMap<String,Set<String>>();
|
||||
userPermissionsCache = new HashMap<String,Set<String>>();
|
||||
defaultPermissionsCache = new HashSet<String>();
|
||||
|
||||
Map<String,Set<String>> userGroupPermissions = loadGroupPermissions();
|
||||
|
||||
if (userGroupPermissions.containsKey("default")) {
|
||||
defaultPermissionsCache = userGroupPermissions.get("default");
|
||||
}
|
||||
|
||||
File file = new File("perms_users.txt");
|
||||
FileReader input = null;
|
||||
@ -149,7 +155,8 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
||||
public boolean hasPermission(String player, String permission) {
|
||||
Set<String> perms = userPermissionsCache.get(player.toLowerCase());
|
||||
if (perms == null) {
|
||||
return false;
|
||||
return defaultPermissionsCache.contains(permission)
|
||||
|| defaultPermissionsCache.contains("*");
|
||||
}
|
||||
|
||||
return perms.contains("*") || perms.contains(permission);
|
||||
|
Loading…
Reference in New Issue
Block a user