Command to view your permissions
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class CmdPerm extends FCommand {
|
||||
|
||||
@@ -25,7 +26,7 @@ public class CmdPerm extends FCommand {
|
||||
this.optionalArgs.put("access", "access");
|
||||
|
||||
this.permission = Permission.PERMISSIONS.node;
|
||||
this.disableOnLock = false;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
@@ -35,8 +36,10 @@ public class CmdPerm extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (optionalArgs.size() == 0) {
|
||||
// TODO: Open the GUI.
|
||||
if (args.size() == 0) {
|
||||
for (String s : getLines()) {
|
||||
msg(s);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,6 +96,35 @@ 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());
|
||||
}
|
||||
|
||||
private List<String> getLines() {
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
lines.add(TL.COMMAND_PERM_TOP.toString());
|
||||
|
||||
for (PermissableAction action : PermissableAction.values()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(action.getName()).append(" ");
|
||||
|
||||
// Roles except admin
|
||||
for (Role role : Role.values()) {
|
||||
if (role != Role.ADMIN) {
|
||||
sb.append(myFaction.getAccess(role, action).getName()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
// Relations except Member
|
||||
for (Relation relation : Relation.values()) {
|
||||
if (relation != Relation.MEMBER) {
|
||||
sb.append(myFaction.getAccess(relation, action).getName()).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
lines.add(sb.toString().trim());
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_PERM_DESCRIPTION;
|
||||
|
||||
Reference in New Issue
Block a user