Factions/src/com/massivecraft/factions/cmd/CmdFlag.java

71 lines
1.7 KiB
Java
Raw Normal View History

2011-10-23 20:50:49 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.FFlag;
2011-10-23 20:50:49 +02:00
import com.massivecraft.factions.struct.Permission;
public class CmdFlag extends FCommand
{
public CmdFlag()
{
super();
this.aliases.add("flag");
//this.requiredArgs.add("");
this.optionalArgs.put("faction", "your");
this.optionalArgs.put("flag", "all");
2012-05-09 06:29:52 +02:00
this.optionalArgs.put("yes/no", "read");
2011-10-23 20:50:49 +02:00
this.permission = Permission.FLAG.node;
this.disableOnLock = true;
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))
{
msg(p.txt.titleize("Flags for " + faction.describeTo(fme, true)));
for (FFlag flag : FFlag.values())
2011-10-23 20:50:49 +02:00
{
msg(flag.getStateInfo(faction.getFlag(flag), true));
}
return;
}
FFlag flag = this.argAsFactionFlag(1);
2011-10-23 20:50:49 +02:00
if (flag == null) return;
if ( ! this.argIsSet(2))
{
msg(p.txt.titleize("Flag for " + faction.describeTo(fme, true)));
2011-10-23 20:50:49 +02:00
msg(flag.getStateInfo(faction.getFlag(flag), true));
return;
}
Boolean targetValue = this.argAsBool(2);
if (targetValue == null) return;
// Do the sender have the right to change flags?
if ( ! Permission.FLAG_SET.has(sender, true)) return;
2011-10-23 20:50:49 +02:00
// Do the change
msg(p.txt.titleize("Flag for " + faction.describeTo(fme, true)));
2011-10-23 20:50:49 +02:00
faction.setFlag(flag, targetValue);
msg(flag.getStateInfo(faction.getFlag(flag), true));
}
}