2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-07-18 22:06:02 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
|
|
|
import com.massivecraft.factions.FLocation;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
|
2011-10-09 20:10:19 +02:00
|
|
|
public class CmdAutoClaim extends FCommand
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2011-10-09 20:10:19 +02:00
|
|
|
public CmdAutoClaim()
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.aliases.add("autoclaim");
|
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
|
|
|
this.optionalArgs.put("on/off", "flipp");
|
|
|
|
|
2011-10-09 21:57:43 +02:00
|
|
|
this.permission = Permission.AUTOCLAIM.node;
|
|
|
|
this.disableOnLock = true;
|
2011-10-09 14:53:38 +02:00
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
|
|
|
senderMustBeMember = false;
|
|
|
|
senderMustBeModerator = true;
|
|
|
|
senderMustBeAdmin = false;
|
2011-06-10 21:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-09 14:53:38 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
|
|
|
boolean enabled = this.argAsBool(0, ! fme.isAutoClaimEnabled());
|
|
|
|
|
|
|
|
fme.setIsAutoClaimEnabled(enabled);
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
if ( ! enabled)
|
|
|
|
{
|
|
|
|
sendMessageParsed("<i>Auto-claiming of land disabled.");
|
2011-06-10 21:26:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
FLocation flocation = new FLocation(fme);
|
2011-06-10 21:26:12 +02:00
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
if (Conf.worldsNoClaiming.contains(flocation.getWorldName()))
|
|
|
|
{
|
|
|
|
sendMessageParsed("<b>Sorry, this world has land claiming disabled.");
|
|
|
|
fme.setIsAutoClaimEnabled(false);
|
2011-06-10 21:26:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
if (myFaction.getLandRounded() >= myFaction.getPowerRounded())
|
|
|
|
{
|
|
|
|
sendMessageParsed("<b>You can't claim more land! You need more power!");
|
|
|
|
fme.setIsAutoClaimEnabled(false);
|
2011-06-10 21:26:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-10-09 14:53:38 +02:00
|
|
|
sendMessageParsed("<i>Auto-claiming of land enabled.");
|
|
|
|
fme.attemptClaim(false);
|
2011-06-10 21:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|