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;
@ -29,9 +28,6 @@ public class CmdFactionsUnclaim extends FCommand
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,22 +629,29 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
return true; return true;
} }
if (!this.isUsingAdminMode() && newFaction.isNormal()) if (!this.isUsingAdminMode())
{
if (newFaction.isNormal())
{ {
int ownedLand = newFaction.getLandCount();
if (mconf.worldsNoClaiming.contains(ps.getWorld())) if (mconf.worldsNoClaiming.contains(ps.getWorld()))
{ {
msg("<b>Sorry, this world has land claiming disabled."); msg("<b>Sorry, this world has land claiming disabled.");
return false; return false;
} }
if (!FPerm.TERRITORY.has(this, newFaction, true))
{
return false;
}
if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers) if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers)
{ {
msg("Factions must have at least <h>%s<b> members to claim land.", uconf.claimsRequireMinFactionMembers); msg("Factions must have at least <h>%s<b> members to claim land.", uconf.claimsRequireMinFactionMembers);
return false; return false;
} }
int ownedLand = newFaction.getLandCount();
if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER)) if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER))
{ {
msg("<b>Limit reached. You can't claim more land."); msg("<b>Limit reached. You can't claim more land.");
@ -655,6 +663,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
msg("<b>You can't claim more land. You need more power."); msg("<b>You can't claim more land. You need more power.");
return false; return false;
} }
}
if (oldFaction.isNormal()) if (oldFaction.isNormal())
{ {
@ -689,6 +698,8 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
return false; return false;
} }
if (!FPerm.TERRITORY.has(this, oldFaction, false))
{
if (!oldFaction.hasLandInflation()) if (!oldFaction.hasLandInflation())
{ {
msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this)); msg("%s<i> owns this land and is strong enough to keep it.", oldFaction.getName(this));
@ -702,6 +713,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
} }
} }
} }
}
// Event // Event
FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction); FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction);