Fix setting perms.
Annoyingly setting them to und by default now
This commit is contained in:
parent
9f8c2e3905
commit
a034030ba5
@ -5,6 +5,7 @@ import com.massivecraft.factions.struct.Permission;
|
|||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
import com.massivecraft.factions.zcore.fperms.Access;
|
import com.massivecraft.factions.zcore.fperms.Access;
|
||||||
|
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
|
|
||||||
@ -47,22 +48,23 @@ public class CmdPerm extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Relation> relations = new HashSet<>();
|
Set<Permissable> permissables = new HashSet<>();
|
||||||
Set<PermissableAction> permissableActions = new HashSet<>();
|
Set<PermissableAction> permissableActions = new HashSet<>();
|
||||||
|
|
||||||
boolean allRelations = argAsString(0).equalsIgnoreCase("all");
|
boolean allRelations = argAsString(0).equalsIgnoreCase("all");
|
||||||
boolean allActions = argAsString(1).equalsIgnoreCase("all");
|
boolean allActions = argAsString(1).equalsIgnoreCase("all");
|
||||||
|
|
||||||
if (allRelations) {
|
if (allRelations) {
|
||||||
relations.addAll(Arrays.asList(Relation.values()));
|
permissables.addAll(myFaction.getPermissions().keySet());
|
||||||
} else {
|
} else {
|
||||||
Relation relation = Relation.fromString(argAsString(0));
|
Permissable permissable = getPermissable(argAsString(0));
|
||||||
if (relation == null) {
|
|
||||||
|
if (permissable == null) {
|
||||||
fme.msg(TL.COMMAND_PERM_INVALID_RELATION);
|
fme.msg(TL.COMMAND_PERM_INVALID_RELATION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
relations.add(relation);
|
permissables.add(permissable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allActions) {
|
if (allActions) {
|
||||||
@ -84,9 +86,9 @@ public class CmdPerm extends FCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Relation relation : relations) {
|
for (Permissable permissable : permissables) {
|
||||||
for (PermissableAction permissableAction : permissableActions) {
|
for (PermissableAction permissableAction : permissableActions) {
|
||||||
fme.getFaction().setPermission(relation, permissableAction, access);
|
fme.getFaction().setPermission(permissable, permissableAction, access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +96,19 @@ public class CmdPerm extends FCommand {
|
|||||||
P.p.log(String.format(TL.COMMAND_PERM_SET.toString(), argAsString(1), access.name(), argAsString(0)) + " for faction " + fme.getTag());
|
P.p.log(String.format(TL.COMMAND_PERM_SET.toString(), argAsString(1), access.name(), argAsString(0)) + " for faction " + fme.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Permissable getPermissable(String name) {
|
||||||
|
try {
|
||||||
|
return Relation.valueOf(name.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Role.valueOf(name.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> getLines() {
|
private List<String> getLines() {
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -366,6 +366,10 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
|||||||
return Access.UNDEFINED;
|
return Access.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Permissable, Map<PermissableAction, Access>> getAccessMap() {
|
||||||
|
return Collections.unmodifiableMap(permissions);
|
||||||
|
}
|
||||||
|
|
||||||
public void setPermission(Permissable permissable, PermissableAction permissableAction, Access access) {
|
public void setPermission(Permissable permissable, PermissableAction permissableAction, Access access) {
|
||||||
Map<PermissableAction, Access> accessMap = permissions.get(permissable);
|
Map<PermissableAction, Access> accessMap = permissions.get(permissable);
|
||||||
if (accessMap == null) {
|
if (accessMap == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user