Factions/src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java
2013-04-16 11:27:03 +02:00

41 lines
1.1 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
public class CmdFactionsAutoClaim extends FCommand
{
public CmdFactionsAutoClaim()
{
this.addAliases("autoclaim");
this.addOptionalArg("faction", "you");
this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node));
this.addRequirements(ReqIsPlayer.get());
}
@Override
public void perform()
{
Faction forFaction = this.arg(0, ARFaction.get(), myFaction);
if (forFaction == null || forFaction == fme.getAutoClaimFor())
{
fme.setAutoClaimFor(null);
msg("<i>Auto-claiming of land disabled.");
return;
}
if ( ! FPerm.TERRITORY.has(fme, forFaction, true)) return;
fme.setAutoClaimFor(forFaction);
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));
fme.attemptClaim(forFaction, me.getLocation(), true);
}
}