Attempt 1 at fixing the claim permission bug.

This commit is contained in:
Olof Larsson 2013-05-13 07:21:11 +02:00
parent 509e7c1711
commit 81d79775f8
2 changed files with 45 additions and 37 deletions

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer; import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
@ -28,9 +27,6 @@ public class CmdFactionsUnclaim extends FCommand
// Args // Args
PS chunk = PS.valueOf(me).getChunk(true); PS chunk = PS.valueOf(me).getChunk(true);
Faction newFaction = FactionColls.get().get(me).getNone(); Faction newFaction = FactionColls.get().get(me).getNone();
// FPerm
if (!FPerm.TERRITORY.has(usender, usenderFaction, true)) return;
// Apply // Apply
if (usender.tryClaim(newFaction, chunk, true, true)) return; if (usender.tryClaim(newFaction, chunk, true, true)) return;

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import com.massivecraft.factions.EconomyParticipator; import com.massivecraft.factions.EconomyParticipator;
import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Lang; import com.massivecraft.factions.Lang;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
@ -628,32 +629,40 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
return true; return true;
} }
if (!this.isUsingAdminMode() && newFaction.isNormal()) if (!this.isUsingAdminMode())
{ {
int ownedLand = newFaction.getLandCount(); if (newFaction.isNormal())
if (mconf.worldsNoClaiming.contains(ps.getWorld()))
{ {
msg("<b>Sorry, this world has land claiming disabled."); if (mconf.worldsNoClaiming.contains(ps.getWorld()))
return false; {
} msg("<b>Sorry, this world has land claiming disabled.");
return false;
if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers) }
{
msg("Factions must have at least <h>%s<b> members to claim land.", uconf.claimsRequireMinFactionMembers); if (!FPerm.TERRITORY.has(this, newFaction, true))
return false; {
} return false;
}
if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER))
{ if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers)
msg("<b>Limit reached. You can't claim more land."); {
return false; msg("Factions must have at least <h>%s<b> members to claim land.", uconf.claimsRequireMinFactionMembers);
} return false;
}
if (ownedLand >= newFaction.getPowerRounded())
{ int ownedLand = newFaction.getLandCount();
msg("<b>You can't claim more land. You need more power.");
return false; if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER))
{
msg("<b>Limit reached. You can't claim more land.");
return false;
}
if (ownedLand >= newFaction.getPowerRounded())
{
msg("<b>You can't claim more land. You need more power.");
return false;
}
} }
if (oldFaction.isNormal()) if (oldFaction.isNormal())
@ -689,16 +698,19 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
return false; return false;
} }
if (!oldFaction.hasLandInflation()) if (!FPerm.TERRITORY.has(this, oldFaction, false))
{ {
msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this)); if (!oldFaction.hasLandInflation())
return false; {
} msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this));
return false;
if ( ! BoardColls.get().isBorderPs(ps)) }
{
msg("<b>You must start claiming land at the border of the territory."); if ( ! BoardColls.get().isBorderPs(ps))
return false; {
msg("<b>You must start claiming land at the border of the territory.");
return false;
}
} }
} }
} }