From 9f8c2e3905dee5cb4ae1b8b918b94d416bd7b160 Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Sun, 11 Feb 2018 17:22:25 -0800 Subject: [PATCH] Revert "Don't set perms to undefined by default" This reverts commit e91fc8f15af2da855aad881369b26f3bb7ecbc1f. --- .../factions/zcore/persist/MemoryFaction.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java index 49ba0435..dcbfdcc2 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFaction.java @@ -332,8 +332,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { Map accessMap = permissions.get(permissable); if (accessMap != null && accessMap.containsKey(permissableAction)) { - Access access = accessMap.get(permissableAction); - return access != null ? access : Access.UNDEFINED; + return accessMap.get(permissableAction); } return Access.UNDEFINED; @@ -378,7 +377,26 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator { public void resetPerms() { P.p.log(Level.WARNING, "Resetting permissions for Faction: " + tag); + permissions.clear(); + + // First populate a map with undefined as the permission for each action. + Map 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); + } + } } /**