Revert "Don't set perms to undefined by default"

This reverts commit e91fc8f15a.
This commit is contained in:
Trent Hensler 2018-02-11 17:22:25 -08:00
parent f51de51734
commit 9f8c2e3905

View File

@ -332,8 +332,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
Map<PermissableAction, Access> accessMap = permissions.get(permissable); Map<PermissableAction, Access> accessMap = permissions.get(permissable);
if (accessMap != null && accessMap.containsKey(permissableAction)) { if (accessMap != null && accessMap.containsKey(permissableAction)) {
Access access = accessMap.get(permissableAction); return accessMap.get(permissableAction);
return access != null ? access : Access.UNDEFINED;
} }
return Access.UNDEFINED; return Access.UNDEFINED;
@ -378,7 +377,26 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
public void resetPerms() { public void resetPerms() {
P.p.log(Level.WARNING, "Resetting permissions for Faction: " + tag); P.p.log(Level.WARNING, "Resetting permissions for Faction: " + tag);
permissions.clear(); permissions.clear();
// First populate a map with undefined as the permission for each action.
Map<PermissableAction, Access> freshMap = new HashMap<>();
for (PermissableAction permissableAction : PermissableAction.values()) {
freshMap.put(permissableAction, Access.UNDEFINED);
}
// Put the map in there for each relation.
for (Relation relation : Relation.values()) {
permissions.put(relation, freshMap);
}
// And each role.
for (Role role : Role.values()) {
if (role != Role.ADMIN) {
permissions.put(role, freshMap);
}
}
} }
/** /**