From 1df563890302389440f771f8f4882c2a8a4cdc15 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 19 Apr 2013 08:20:38 +0200 Subject: [PATCH] Adding in friend-state into the Rel enum and removing the config option. --- src/com/massivecraft/factions/ConfServer.java | 3 --- src/com/massivecraft/factions/Rel.java | 24 ++++++++++++------- .../listeners/FactionsListenerMain.java | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index 164e8899..998005fc 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -197,9 +197,6 @@ public class ConfServer extends SimpleConfig public static double homesTeleportAllowedEnemyDistance = 32.0; public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; - // TODO: This one should not be in the config should it? It should be built into the enum? - public static Rel friendlyFireFromRel = Rel.TRUCE; - public static boolean disablePVPForFactionlessPlayers = false; public static boolean enablePVPAgainstFactionlessInAttackersLand = false; diff --git a/src/com/massivecraft/factions/Rel.java b/src/com/massivecraft/factions/Rel.java index b9a03165..fa56e99b 100644 --- a/src/com/massivecraft/factions/Rel.java +++ b/src/com/massivecraft/factions/Rel.java @@ -9,14 +9,14 @@ public enum Rel // ENUM // -------------------------------------------- // - LEADER (70, "your faction leader", "your faction leader", "", ""), - OFFICER (60, "an officer in your faction", "officers in your faction", "", ""), - MEMBER (50, "a member in your faction", "members in your faction", "your faction", "your factions"), - RECRUIT (45, "a recruit in your faction", "recruits in your faction", "", ""), - ALLY (40, "an ally", "allies", "an allied faction", "allied factions"), - TRUCE (30, "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce"), - NEUTRAL (20, "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions"), - ENEMY (10, "an enemy", "enemies", "an enemy faction", "enemy factions"), + LEADER (70, true, "your faction leader", "your faction leader", "", ""), + OFFICER (60, true, "an officer in your faction", "officers in your faction", "", ""), + MEMBER (50, true, "a member in your faction", "members in your faction", "your faction", "your factions"), + RECRUIT (45, true, "a recruit in your faction", "recruits in your faction", "", ""), + ALLY (40, true, "an ally", "allies", "an allied faction", "allied factions"), + TRUCE (30, true, "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce"), + NEUTRAL (20, false, "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions"), + ENEMY (10, false, "an enemy", "enemies", "an enemy faction", "enemy factions"), // END OF LIST ; @@ -26,6 +26,11 @@ public enum Rel // -------------------------------------------- // private final int value; + + // Used for friendly fire. + private final boolean friend; + public boolean isFriend() { return this.friend; } + private final String descPlayerOne; public String getDescPlayerOne() { return this.descPlayerOne; } @@ -42,9 +47,10 @@ public enum Rel // CONSTRUCT // -------------------------------------------- // - private Rel(final int value, final String descPlayerOne, final String descPlayerMany, final String descFactionOne, final String descFactionMany) + private Rel(final int value, final boolean friend, final String descPlayerOne, final String descPlayerMany, final String descFactionOne, final String descFactionMany) { this.value = value; + this.friend = friend; this.descPlayerOne = descPlayerOne; this.descPlayerMany = descPlayerMany; this.descFactionOne = descFactionOne; diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java index 6bb5d1f0..f94f0273 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -211,7 +211,7 @@ public class FactionsListenerMain implements Listener Rel relation = defendFaction.getRelationTo(attackFaction); // Check the relation - if (fdefender.hasFaction() && relation.isAtLeast(ConfServer.friendlyFireFromRel) && defenderPsFaction.getFlag(FFlag.FRIENDLYFIRE) == false) + if (fdefender.hasFaction() && relation.isFriend() && defenderPsFaction.getFlag(FFlag.FRIENDLYFIRE) == false) { if (notify) fattacker.msg("You can't hurt %s.", relation.getDescPlayerMany()); return false;