2011-10-23 23:17:02 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-24 01:37:51 +02:00
|
|
|
import com.massivecraft.factions.struct.FPerm;
|
2011-10-23 23:17:02 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
import com.massivecraft.factions.struct.Rel;
|
|
|
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
|
|
|
|
|
|
|
public class CmdPerm extends FCommand
|
|
|
|
{
|
|
|
|
|
|
|
|
public CmdPerm()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.aliases.add("perm");
|
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("faction", "your");
|
|
|
|
this.optionalArgs.put("perm", "all");
|
|
|
|
this.optionalArgs.put("relationdelta", "read");
|
|
|
|
|
|
|
|
this.permission = Permission.PERM.node;
|
|
|
|
this.disableOnLock = true;
|
|
|
|
|
|
|
|
this.errorOnToManyArgs = false;
|
|
|
|
|
|
|
|
senderMustBePlayer = false;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeOfficer = false;
|
|
|
|
senderMustBeLeader = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
|
|
|
Faction faction = myFaction;
|
|
|
|
if (this.argIsSet(0))
|
|
|
|
{
|
|
|
|
faction = this.argAsFaction(0);
|
|
|
|
}
|
|
|
|
if (faction == null) return;
|
|
|
|
|
|
|
|
if ( ! this.argIsSet(1))
|
|
|
|
{
|
2011-10-24 09:28:08 +02:00
|
|
|
msg(p.txt.titleize("Perms for " + faction.describeTo(fme)));
|
2011-10-24 01:37:51 +02:00
|
|
|
for (FPerm perm : FPerm.values())
|
2011-10-23 23:17:02 +02:00
|
|
|
{
|
2011-10-24 01:37:51 +02:00
|
|
|
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
2011-10-23 23:17:02 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-24 01:37:51 +02:00
|
|
|
FPerm perm = this.argAsFactionPerm(1);
|
2011-10-23 23:17:02 +02:00
|
|
|
if (perm == null) return;
|
|
|
|
if ( ! this.argIsSet(2))
|
|
|
|
{
|
2011-10-24 09:28:08 +02:00
|
|
|
msg(p.txt.titleize("Perm for " + faction.describeTo(fme)));
|
2011-10-24 01:37:51 +02:00
|
|
|
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
2011-10-23 23:17:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-24 01:37:51 +02:00
|
|
|
Set<Rel> targetValue = FPerm.parseRelDeltas(TextUtil.implode(args.subList(2, args.size()), " "), faction.getPermittedRelations(perm));
|
2011-10-23 23:17:02 +02:00
|
|
|
|
|
|
|
// Do the sender have the right to change perms for this faction?
|
|
|
|
if (Permission.PERM_ANY.has(sender))
|
|
|
|
{
|
|
|
|
// This sender may modify any perm for anyone
|
|
|
|
}
|
|
|
|
else if (faction != myFaction)
|
|
|
|
{
|
|
|
|
msg("<b>You are not a member in that faction.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (fme.getRole().isLessThan(Rel.OFFICER))
|
|
|
|
{
|
|
|
|
msg("<b>You must be faction leader or officer to change your faction permissions.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do the change
|
2011-10-24 01:37:51 +02:00
|
|
|
faction.setPermittedRelations(perm, targetValue);
|
2011-10-24 09:28:08 +02:00
|
|
|
msg(p.txt.titleize("Perm for " + faction.describeTo(fme)));
|
2011-10-24 01:37:51 +02:00
|
|
|
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
|
2011-10-23 23:17:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|