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;
|
2013-04-09 12:56:29 +02:00
|
|
|
import com.massivecraft.factions.Perm;
|
2013-04-16 11:27:03 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARFFlag;
|
2013-04-16 11:05:49 +02:00
|
|
|
import com.massivecraft.factions.cmd.arg.ARFaction;
|
2013-04-25 13:25:15 +02:00
|
|
|
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
|
2013-04-22 09:37:53 +02:00
|
|
|
import com.massivecraft.factions.entity.Faction;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
|
|
|
import com.massivecraft.massivecore.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-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
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
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Aliases
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("flag");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Args
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addOptionalArg("faction", "you");
|
|
|
|
this.addOptionalArg("flag", "all");
|
|
|
|
this.addOptionalArg("yes/no", "read");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Requirements
|
2013-04-25 13:25:15 +02:00
|
|
|
this.addRequirements(ReqFactionsEnabled.get());
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addRequirements(ReqHasPerm.get(Perm.FLAG.node));
|
2011-10-23 20:50:49 +02:00
|
|
|
}
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
2011-10-23 20:50:49 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void perform()
|
2013-04-25 13:25:15 +02:00
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction);
|
2011-10-23 20:50:49 +02:00
|
|
|
if (faction == null) return;
|
|
|
|
|
|
|
|
if ( ! this.argIsSet(1))
|
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
msg(Txt.titleize("Flags for " + faction.describeTo(usender, 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;
|
|
|
|
}
|
|
|
|
|
2013-04-16 11:27:03 +02:00
|
|
|
FFlag flag = this.arg(1, ARFFlag.get());
|
2011-10-23 20:50:49 +02:00
|
|
|
if (flag == null) return;
|
2013-04-16 11:27:03 +02:00
|
|
|
|
2011-10-23 20:50:49 +02:00
|
|
|
if ( ! this.argIsSet(2))
|
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
msg(Txt.titleize("Flag for " + faction.describeTo(usender, true)));
|
2011-10-23 20:50:49 +02:00
|
|
|
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-16 11:27:03 +02:00
|
|
|
Boolean targetValue = this.arg(2, ARBoolean.get());
|
2011-10-23 20:50:49 +02:00
|
|
|
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-25 07:29:19 +02:00
|
|
|
msg(Txt.titleize("Flag for " + faction.describeTo(usender, true)));
|
2011-10-23 20:50:49 +02:00
|
|
|
faction.setFlag(flag, targetValue);
|
|
|
|
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|