Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdAutoClaim.java

50 lines
1.4 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
2014-04-04 20:55:21 +02:00
public class CmdAutoClaim extends FCommand {
2014-04-04 20:55:21 +02:00
public CmdAutoClaim() {
2014-07-01 22:10:18 +02:00
super();
this.aliases.add("autoclaim");
2014-04-04 20:55:21 +02:00
//this.requiredArgs.add("");
this.optionalArgs.put("faction", "your");
2014-07-01 22:10:18 +02:00
this.permission = Permission.AUTOCLAIM.node;
this.disableOnLock = true;
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
2014-04-04 20:55:21 +02:00
}
@Override
public void perform() {
Faction forFaction = this.argAsFaction(0, myFaction);
if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
2014-07-01 22:10:18 +02:00
fme.setAutoClaimFor(null);
msg("<i>Auto-claiming of land disabled.");
return;
2014-04-04 20:55:21 +02:00
}
if (!fme.canClaimForFaction(forFaction)) {
2014-07-01 21:52:40 +02:00
if (myFaction == forFaction) {
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
2014-07-01 22:10:18 +02:00
} else {
msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme));
}
2014-04-04 20:55:21 +02:00
return;
}
fme.setAutoClaimFor(forFaction);
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));
fme.attemptClaim(forFaction, me.getLocation(), true);
}
}