Fixed Co-Leader Default Permissions

This commit is contained in:
Driftay 2019-12-21 23:52:14 -05:00
parent 11d9f9230b
commit 91ca08e66b
3 changed files with 24 additions and 29 deletions

View File

@ -552,7 +552,6 @@ public class Conf {
safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE); safeZoneNerfedCreatureTypes.add(EntityType.ZOMBIE);
// Is this called lazy load? // Is this called lazy load?
defaultFactionPermissions.put("LEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true)); defaultFactionPermissions.put("COLEADER", new DefaultPermissions(true));
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true)); defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false)); defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false));

View File

@ -37,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
public abstract class MemoryFaction implements Faction, EconomyParticipator { public abstract class MemoryFaction implements Faction, EconomyParticipator {
public HashMap<Integer, String> rules = new HashMap<Integer, String>(); public HashMap<Integer, String> rules = new HashMap<>();
public int tnt; public int tnt;
public Location checkpoint; public Location checkpoint;
public LazyLocation vault; public LazyLocation vault;
@ -186,7 +186,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
public void addAnnouncement(FPlayer fPlayer, String msg) { public void addAnnouncement(FPlayer fPlayer, String msg) {
List<String> list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList<String>(); List<String> list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList<>();
list.add(msg); list.add(msg);
announcements.put(fPlayer.getId(), list); announcements.put(fPlayer.getId(), list);
} }
@ -450,8 +450,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
vault = null; vault = null;
return; return;
} }
LazyLocation newlocation = new LazyLocation(vaultLocation); vault = new LazyLocation(vaultLocation);
vault = newlocation;
} }
public int getUpgrade(UpgradeType upgrade) { public int getUpgrade(UpgradeType upgrade) {
@ -899,47 +898,44 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
} }
public void resetPerms() { public void resetPerms() {
FactionsPlugin.getInstance().log(Level.WARNING, "Resetting permissions for Faction: " + tag); FactionsPlugin.instance.log(Level.WARNING, "Resetting permissions for Faction: " + this.tag);
permissions.clear(); permissions.clear();
// First populate a map with undefined as the permission for each action. // First populate a map with undefined as the permission for each action.
Map<PermissableAction, Access> freshMap = new HashMap<>(); Map<PermissableAction, Access> freshMap = new HashMap<>();
for (PermissableAction permissableAction : PermissableAction.values()) { for (PermissableAction action : PermissableAction.values()) freshMap.put(action, Access.DENY);
freshMap.put(permissableAction, Access.UNDEFINED);
}
// Put the map in there for each relation. // Put the map in there for each relation.
for (Relation relation : Relation.values()) { for (Relation relation : Relation.values()) {
if (relation != Relation.MEMBER) { if (relation == Relation.MEMBER) continue;
permissions.put(relation, new HashMap<>(freshMap)); permissions.put(relation, new HashMap<>(freshMap));
}
} }
// And each role. // And each role.
for (Role role : Role.values()) { for (Role role : Role.values()) {
if (role != Role.LEADER) { if (role == Role.LEADER) continue;
permissions.put(role, new HashMap<>(freshMap)); permissions.put(role, new HashMap<>(freshMap));
}
} }
} }
public void setDefaultPerms() { public void setDefaultPerms() {
Map<PermissableAction, Access> defaultMap = new HashMap<>(); Map<PermissableAction, Access> defaultMap = new HashMap<>();
for (PermissableAction action : PermissableAction.values()) defaultMap.put(action, Access.UNDEFINED); for (PermissableAction action : PermissableAction.values()) defaultMap.put(action, Access.DENY);
for (Relation rel : Relation.values()) { for (Relation rel : Relation.values()) {
if (rel != Relation.MEMBER) { if (rel == Relation.MEMBER) continue;
if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) {
permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
} else permissions.put(rel, new HashMap<>(defaultMap));
}
}
for (Role rel : Role.values()) {
if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) { if (Conf.defaultFactionPermissions.containsKey(rel.nicename.toUpperCase())) {
permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase()))); permissions.put(rel, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(rel.nicename.toUpperCase())));
} else permissions.put(rel, new HashMap<>(defaultMap)); } else permissions.put(rel, new HashMap<>(defaultMap));
} }
for (Role role : Role.values()) {
if (role == Role.LEADER) continue;
if (Conf.defaultFactionPermissions.containsKey(role.nicename.toUpperCase())) {
permissions.put(role, PermissableAction.fromDefaults(Conf.defaultFactionPermissions.get(role.nicename.toUpperCase())));
} else permissions.put(role, new HashMap<>(defaultMap));
}
} }
/** /**

View File

@ -1145,11 +1145,11 @@ public enum TL {
/** /**
* Roles * Roles
*/ */
ROLE_LEADER("Leader"), ROLE_LEADER("leader"),
ROLE_COLEADER("Co-Leader"), ROLE_COLEADER("coleader"),
ROLE_MODERATOR("Moderator"), ROLE_MODERATOR("moderator"),
ROLE_NORMAL("Normal Member"), ROLE_NORMAL("normal member"),
ROLE_RECRUIT("Recruit"), ROLE_RECRUIT("recruit"),
/** /**
* Region types. * Region types.