From 81d79775f84dc5129d376702c4f6248207a99a27 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 13 May 2013 07:21:11 +0200 Subject: [PATCH] Attempt 1 at fixing the claim permission bug. --- .../factions/cmd/CmdFactionsUnclaim.java | 4 - .../massivecraft/factions/entity/UPlayer.java | 78 +++++++++++-------- 2 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index 7059336f..b25b3bc2 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -4,7 +4,6 @@ import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColls; -import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Perm; import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqIsPlayer; @@ -28,9 +27,6 @@ public class CmdFactionsUnclaim extends FCommand // Args PS chunk = PS.valueOf(me).getChunk(true); Faction newFaction = FactionColls.get().get(me).getNone(); - - // FPerm - if (!FPerm.TERRITORY.has(usender, usenderFaction, true)) return; // Apply if (usender.tryClaim(newFaction, chunk, true, true)) return; diff --git a/src/com/massivecraft/factions/entity/UPlayer.java b/src/com/massivecraft/factions/entity/UPlayer.java index b8cd5d0e..e20c3504 100644 --- a/src/com/massivecraft/factions/entity/UPlayer.java +++ b/src/com/massivecraft/factions/entity/UPlayer.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Player; import com.massivecraft.factions.EconomyParticipator; import com.massivecraft.factions.FFlag; +import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Lang; import com.massivecraft.factions.Rel; @@ -628,32 +629,40 @@ public class UPlayer extends SenderEntity implements EconomyParticipato return true; } - if (!this.isUsingAdminMode() && newFaction.isNormal()) + if (!this.isUsingAdminMode()) { - int ownedLand = newFaction.getLandCount(); - - if (mconf.worldsNoClaiming.contains(ps.getWorld())) + if (newFaction.isNormal()) { - msg("Sorry, this world has land claiming disabled."); - return false; - } - - if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers) - { - msg("Factions must have at least %s members to claim land.", uconf.claimsRequireMinFactionMembers); - return false; - } - - if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER)) - { - msg("Limit reached. You can't claim more land."); - return false; - } - - if (ownedLand >= newFaction.getPowerRounded()) - { - msg("You can't claim more land. You need more power."); - return false; + if (mconf.worldsNoClaiming.contains(ps.getWorld())) + { + msg("Sorry, this world has land claiming disabled."); + return false; + } + + if (!FPerm.TERRITORY.has(this, newFaction, true)) + { + return false; + } + + if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers) + { + msg("Factions must have at least %s members to claim land.", uconf.claimsRequireMinFactionMembers); + return false; + } + + int ownedLand = newFaction.getLandCount(); + + if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER)) + { + msg("Limit reached. You can't claim more land."); + return false; + } + + if (ownedLand >= newFaction.getPowerRounded()) + { + msg("You can't claim more land. You need more power."); + return false; + } } if (oldFaction.isNormal()) @@ -689,16 +698,19 @@ public class UPlayer extends SenderEntity implements EconomyParticipato return false; } - if (!oldFaction.hasLandInflation()) + if (!FPerm.TERRITORY.has(this, oldFaction, false)) { - msg("%s owns this land and is strong enough to keep it.", oldFaction.getName(this)); - return false; - } - - if ( ! BoardColls.get().isBorderPs(ps)) - { - msg("You must start claiming land at the border of the territory."); - return false; + if (!oldFaction.hasLandInflation()) + { + msg("%s owns this land and is strong enough to keep it.", oldFaction.getName(this)); + return false; + } + + if ( ! BoardColls.get().isBorderPs(ps)) + { + msg("You must start claiming land at the border of the territory."); + return false; + } } } }