Factions3/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java

50 lines
1.4 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
2013-04-09 13:15:25 +02:00
import com.massivecraft.factions.ConfServer;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Faction;
2013-04-09 12:58:39 +02:00
import com.massivecraft.factions.FactionColl;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
2013-04-16 11:05:49 +02:00
import com.massivecraft.mcore.cmd.arg.ARBoolean;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
2013-04-10 13:12:22 +02:00
public class CmdFactionsOpen extends FCommand
2011-10-09 18:35:39 +02:00
{
2013-04-10 13:12:22 +02:00
public CmdFactionsOpen()
2011-10-09 18:35:39 +02:00
{
2013-04-16 10:11:59 +02:00
this.addAliases("open");
2011-10-09 18:35:39 +02:00
this.addOptionalArg("yes/no", "toggle");
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.OPEN.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
@Override
2011-10-09 18:35:39 +02:00
public void perform()
{
2013-04-16 11:05:49 +02:00
Boolean target = this.arg(0, ARBoolean.get(), !myFaction.isOpen());
if (target == null) return;
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
2013-04-09 13:15:25 +02:00
if ( ! payForCommand(ConfServer.econCostOpen, "to open or close the faction", "for opening or closing the faction")) return;
2013-04-16 11:05:49 +02:00
myFaction.setOpen(target);
String descTarget = myFaction.isOpen() ? "open" : "closed";
// Inform
2013-04-16 11:05:49 +02:00
myFaction.msg("%s<i> changed the faction to <h>%s<i>.", fme.describeTo(myFaction, true), descTarget);
for (Faction faction : FactionColl.get().getAll())
2011-10-09 18:35:39 +02:00
{
if (faction == myFaction)
{
continue;
}
2013-04-16 11:05:49 +02:00
faction.msg("<i>The faction %s<i> is now %s", myFaction.getTag(faction), descTarget);
}
}
}