Saber-Factions/src/main/java/com/massivecraft/factions/cmd/CmdAutoClaim.java
2015-01-21 19:25:45 -06:00

56 lines
1.6 KiB
Java

package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.util.TL;
public class CmdAutoClaim extends FCommand {
public CmdAutoClaim() {
super();
this.aliases.add("autoclaim");
//this.requiredArgs.add("");
this.optionalArgs.put("faction", "your");
this.permission = Permission.AUTOCLAIM.node;
this.disableOnLock = true;
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform() {
Faction forFaction = this.argAsFaction(0, myFaction);
if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
fme.setAutoClaimFor(null);
msg(TL.COMMAND_AUTOCLAIM_DISABLED);
return;
}
if (!fme.canClaimForFaction(forFaction)) {
if (myFaction == forFaction) {
msg(TL.COMMAND_AUTOCLAIM_REQUIREDRANK, Role.MODERATOR.getTranslation());
} else {
msg(TL.COMMAND_AUTOCLAIM_OTHERFACTION, forFaction.describeTo(fme));
}
return;
}
fme.setAutoClaimFor(forFaction);
msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(fme));
fme.attemptClaim(forFaction, me.getLocation(), true);
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_AUTOCLAIM_DESCRIPTION;
}
}