Merge with master

This commit is contained in:
Olof Larsson 2011-10-25 17:52:14 +02:00
commit 57c4b70dad
3 changed files with 31 additions and 2 deletions

View File

@ -512,6 +512,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) public boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure)
{ {
String error = null; String error = null;

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
public class CmdAutoClaim extends FCommand public class CmdAutoClaim extends FCommand
{ {
@ -26,13 +27,23 @@ public class CmdAutoClaim extends FCommand
public void perform() public void perform()
{ {
Faction forFaction = this.argAsFaction(0, myFaction); Faction forFaction = this.argAsFaction(0, myFaction);
if (forFaction == null || (forFaction == myFaction && fme.getAutoClaimFor() == myFaction)) if (forFaction == null || forFaction == fme.getAutoClaimFor())
{ {
fme.setAutoClaimFor(null); fme.setAutoClaimFor(null);
msg("<i>Auto-claiming of land disabled."); msg("<i>Auto-claiming of land disabled.");
return; 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); fme.setAutoClaimFor(forFaction);
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme)); msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));

View File

@ -166,7 +166,7 @@ public abstract class FCommand extends MCommand<P>
if (msg && ret == null) 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; return ret;