2011-10-23 20:50:49 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2013-04-09 13:24:55 +02:00
|
|
|
import com.massivecraft.factions.FFlag;
|
2011-10-23 20:50:49 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2013-04-16 10:11:59 +02:00
|
|
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
2013-04-10 10:32:04 +02:00
|
|
|
import com.massivecraft.mcore.util.Txt;
|
2011-10-23 20:50:49 +02:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsFlag extends FCommand
|
2011-10-23 20:50:49 +02:00
|
|
|
{
|
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsFlag()
|
2011-10-23 20:50:49 +02:00
|
|
|
{
|
|
|
|
super();
|
2013-04-16 10:11:59 +02:00
|
|
|
|
|
|
|
this.addAliases("flag");
|
2011-10-23 20:50:49 +02:00
|
|
|
|
|
|
|
//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
|
|
|
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.FLAG.node));
|
2011-10-23 20:50:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
|
|
|
{
|
|
|
|
Faction faction = myFaction;
|
|
|
|
if (this.argIsSet(0))
|
|
|
|
{
|
|
|
|
faction = this.argAsFaction(0);
|
|
|
|
}
|
|
|
|
if (faction == null) return;
|
|
|
|
|
|
|
|
if ( ! this.argIsSet(1))
|
|
|
|
{
|
2013-04-10 10:32:04 +02:00
|
|
|
msg(Txt.titleize("Flags for " + faction.describeTo(fme, true)));
|
2011-10-24 02:33:30 +02:00
|
|
|
for (FFlag flag : FFlag.values())
|
2011-10-23 20:50:49 +02:00
|
|
|
{
|
|
|
|
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-24 02:33:30 +02:00
|
|
|
FFlag flag = this.argAsFactionFlag(1);
|
2011-10-23 20:50:49 +02:00
|
|
|
if (flag == null) return;
|
|
|
|
if ( ! this.argIsSet(2))
|
|
|
|
{
|
2013-04-10 10:32:04 +02:00
|
|
|
msg(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;
|
|
|
|
|
2011-10-25 21:18:08 +02:00
|
|
|
// Do the sender have the right to change flags?
|
2013-04-09 12:56:29 +02:00
|
|
|
if ( ! Perm.FLAG_SET.has(sender, true)) return;
|
2011-10-23 20:50:49 +02:00
|
|
|
|
|
|
|
// Do the change
|
2013-04-10 10:32:04 +02:00
|
|
|
msg(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));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|