autoclaim will now cancel beforehand if player isn't able to claim land for the specified faction

This commit is contained in:
Brettflan 2011-10-25 01:27:58 -05:00
parent 136b69b07f
commit d44ccda211
3 changed files with 31 additions and 2 deletions

View File

@ -632,6 +632,24 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
}
}
public boolean canClaimForFaction(Faction forFaction)
{
if (forFaction.isNone()) return false;
if
(
this.isAdminBypassing()
|| (forFaction == this.getFaction() && this.getRole().isAtLeast(Role.MODERATOR))
|| (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer()))
|| (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer()))
)
{
return true;
}
return false;
}
public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure)
{
String error = null;

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
public class CmdAutoClaim extends FCommand
{
@ -26,13 +27,23 @@ public class CmdAutoClaim extends FCommand
public void perform()
{
Faction forFaction = this.argAsFaction(0, myFaction);
if (forFaction == null || (forFaction == myFaction && fme.getAutoClaimFor() == myFaction))
if (forFaction == null || forFaction == fme.getAutoClaimFor())
{
fme.setAutoClaimFor(null);
msg("<i>Auto-claiming of land disabled.");
return;
}
if (! fme.canClaimForFaction(forFaction))
{
if (myFaction == forFaction)
msg("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
else
msg("<b>You can't claim land for <h>%s<b>.", forFaction.describeTo(fme));
return;
}
fme.setAutoClaimFor(forFaction);
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));

View File

@ -164,7 +164,7 @@ public abstract class FCommand extends MCommand<P>
if (msg && ret == null)
{
this.msg("<b>No player \"<p>%s<b>\" could not be found.", name);
this.msg("<b>No player \"<p>%s<b>\" could be found.", name);
}
return ret;