From 538b387f2fa48d095f7732da6e5fac3efb0f3137 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Fri, 16 Sep 2011 01:45:23 -0500 Subject: [PATCH] Fix for players being able to hurt members of their own faction while in their own land if the "enablePVPAgainstFactionlessInAttackersLand" option is enabled --- .../listeners/FactionsEntityListener.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index 4f22ff2c..c263d099 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -204,21 +204,23 @@ public class FactionsEntityListener extends EntityListener { return true; } - if (!attacker.hasFaction() && Conf.disablePVPForFactionlessPlayers) { + Faction defendFaction = defender.getFaction(); + Faction attackFaction = attacker.getFaction(); + + if (attackFaction.isNone() && Conf.disablePVPForFactionlessPlayers) { attacker.sendMessage("You can't hurt other players until you join a faction."); return false; } - else if (defLocFaction == attacker.getFaction() && Conf.enablePVPAgainstFactionlessInAttackersLand) { - // Allow PVP vs. Factionless in attacker's faction territory - return true; + else if (defendFaction.isNone()) { + if (defLocFaction == attackFaction && Conf.enablePVPAgainstFactionlessInAttackersLand) { + // Allow PVP vs. Factionless in attacker's faction territory + return true; + } + else if (Conf.disablePVPForFactionlessPlayers) { + attacker.sendMessage("You can't hurt players who are not currently in a faction."); + return false; + } } - else if (!defender.hasFaction() && Conf.disablePVPForFactionlessPlayers) { - attacker.sendMessage("You can't hurt players who are not currently in a faction."); - return false; - } - - Faction defendFaction = defender.getFaction(); - Faction attackFaction = attacker.getFaction(); if (defendFaction.isPeaceful()) { attacker.sendMessage("You can't hurt players who are in a peaceful faction.");