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

42 lines
1.2 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
2013-04-16 11:27:03 +02:00
import com.massivecraft.factions.cmd.arg.ARFaction;
2013-04-22 09:37:53 +02:00
import com.massivecraft.factions.entity.Faction;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
2013-04-19 14:24:35 +02:00
import com.massivecraft.mcore.ps.PS;
2013-04-10 13:12:22 +02:00
public class CmdFactionsAutoClaim extends FCommand
{
2013-04-10 13:12:22 +02:00
public CmdFactionsAutoClaim()
{
2013-04-16 10:11:59 +02:00
this.addAliases("autoclaim");
this.addOptionalArg("faction", "you");
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node));
this.addRequirements(ReqIsPlayer.get());
}
@Override
public void perform()
{
2013-04-22 13:03:21 +02:00
Faction forFaction = this.arg(0, ARFaction.get(myFaction), myFaction);
2013-04-24 15:14:15 +02:00
if (forFaction == null || forFaction == fme.getAutoClaimFaction())
{
2013-04-24 15:14:15 +02:00
fme.setAutoClaimFaction(null);
2011-10-10 13:40:24 +02:00
msg("<i>Auto-claiming of land disabled.");
return;
}
2013-04-24 15:14:15 +02:00
if (forFaction.isNormal() && !FPerm.TERRITORY.has(fme, forFaction, true)) return;
2013-04-24 15:14:15 +02:00
fme.setAutoClaimFaction(forFaction);
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));
fme.tryClaim(forFaction, PS.valueOf(me), true, true);
}
}