2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2013-04-09 13:24:55 +02:00
|
|
|
import com.massivecraft.factions.FPerm;
|
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.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;
|
2013-04-25 13:25:15 +02:00
|
|
|
import com.massivecraft.factions.entity.UConf;
|
2014-06-04 14:02:23 +02:00
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
|
|
|
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
|
|
|
import com.massivecraft.massivecore.ps.PS;
|
2011-10-09 14:53:38 +02:00
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public class CmdFactionsAutoClaim extends FCommand
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-10 13:12:22 +02:00
|
|
|
public CmdFactionsAutoClaim()
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-11-11 09:31:04 +01:00
|
|
|
// Aliases
|
2013-04-16 10:11:59 +02:00
|
|
|
this.addAliases("autoclaim");
|
2013-11-11 09:31:04 +01:00
|
|
|
|
|
|
|
// Args
|
2013-04-16 10:30:21 +02:00
|
|
|
this.addOptionalArg("faction", "you");
|
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.AUTOCLAIM.node));
|
2013-04-16 09:48:57 +02:00
|
|
|
this.addRequirements(ReqIsPlayer.get());
|
2011-06-10 21:26:12 +02:00
|
|
|
}
|
|
|
|
|
2013-11-11 09:31:04 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2011-06-10 21:26:12 +02:00
|
|
|
@Override
|
2011-10-09 14:53:38 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
2013-04-25 13:25:15 +02:00
|
|
|
// Check disabled
|
|
|
|
if (UConf.isDisabled(sender, sender)) return;
|
|
|
|
|
|
|
|
// Args
|
2013-04-25 07:29:19 +02:00
|
|
|
Faction forFaction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
|
2013-04-25 13:25:15 +02:00
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
if (forFaction == null || forFaction == usender.getAutoClaimFaction())
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2013-04-25 07:29:19 +02:00
|
|
|
usender.setAutoClaimFaction(null);
|
2011-10-10 13:40:24 +02:00
|
|
|
msg("<i>Auto-claiming of land disabled.");
|
2011-06-10 21:26:12 +02:00
|
|
|
return;
|
|
|
|
}
|
2011-10-25 21:18:08 +02:00
|
|
|
|
2013-04-25 12:04:01 +02:00
|
|
|
// FPerm
|
2013-04-25 07:29:19 +02:00
|
|
|
if (forFaction.isNormal() && !FPerm.TERRITORY.has(usender, forFaction, true)) return;
|
2011-10-22 17:03:49 +02:00
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
usender.setAutoClaimFaction(forFaction);
|
2011-10-22 17:03:49 +02:00
|
|
|
|
2013-04-25 07:29:19 +02:00
|
|
|
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(usender));
|
|
|
|
usender.tryClaim(forFaction, PS.valueOf(me), true, true);
|
2011-06-10 21:26:12 +02:00
|
|
|
}
|
|
|
|
|
2011-10-22 17:03:49 +02:00
|
|
|
}
|