Initial f perm.
TODO: * Add GUI for viewing and changing permissions. * Currently no way to view access for all perms. * Test this because I didn't. * Finish implementation of all permissions, add more.
This commit is contained in:
71
src/main/java/com/massivecraft/factions/cmd/CmdPerm.java
Normal file
71
src/main/java/com/massivecraft/factions/cmd/CmdPerm.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.Action;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdPerm extends FCommand {
|
||||
|
||||
public CmdPerm() {
|
||||
super();
|
||||
this.aliases.add("perm");
|
||||
this.aliases.add("perms");
|
||||
this.aliases.add("permission");
|
||||
this.aliases.add("permissions");
|
||||
|
||||
this.optionalArgs.put("relation", "relation");
|
||||
this.optionalArgs.put("action", "action");
|
||||
this.optionalArgs.put("access", "access");
|
||||
|
||||
this.permission = Permission.SET_PEACEFUL.node;
|
||||
this.disableOnLock = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (optionalArgs.size() == 0) {
|
||||
// TODO: Open the GUI.
|
||||
return;
|
||||
}
|
||||
|
||||
// If not opening GUI, then setting the permission manually.
|
||||
if (args.size() != 3) {
|
||||
fme.msg(TL.COMMAND_PERM_DESCRIPTION);
|
||||
return;
|
||||
}
|
||||
|
||||
Relation relation = Relation.fromString(argAsString(0));
|
||||
Action action = Action.fromString(argAsString(1));
|
||||
Access access = Access.fromString(argAsString(2));
|
||||
if (relation == null) {
|
||||
fme.msg(TL.COMMAND_PERM_INVALID_RELATION);
|
||||
return;
|
||||
}
|
||||
if (action == null) {
|
||||
fme.msg(TL.COMMAND_PERM_INVALID_ACTION);
|
||||
return;
|
||||
}
|
||||
if (access == null) {
|
||||
fme.msg(TL.COMMAND_PERM_INVALID_ACCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
fme.getFaction().setPermission(relation, action, access);
|
||||
fme.msg(TL.COMMAND_PERM_SET, action.getName(), relation.nicename, access.name());
|
||||
P.p.log(String.format(TL.COMMAND_PERM_SET.toString(), action.getName(), relation.nicename, access.name()) + " for faction " + fme.getTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_PERM_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -69,6 +69,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdClaimLine cmdClaimLine = new CmdClaimLine();
|
||||
public CmdTop cmdTop = new CmdTop();
|
||||
public CmdAHome cmdAHome = new CmdAHome();
|
||||
public CmdPerm cmdPerm = new CmdPerm();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@@ -152,6 +153,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdClaimLine);
|
||||
this.addSubCommand(this.cmdTop);
|
||||
this.addSubCommand(this.cmdAHome);
|
||||
this.addSubCommand(this.cmdPerm);
|
||||
if (P.p.isHookedPlayervaults()) {
|
||||
P.p.log("Found playervaults hook, adding /f vault and /f setmaxvault commands.");
|
||||
this.addSubCommand(new CmdSetMaxVaults());
|
||||
|
||||
Reference in New Issue
Block a user