From f38651ca94294f4bcbea35f64cc3439cbe7ce58d Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 1 Aug 2011 19:59:48 -0500 Subject: [PATCH] New conf.json settings "showNeutralFactionsOnMap" and "showEnemyFactionsOnMap" (both default to true) which, if disabled, will hide neutral and enemy factions on the faction map. However, if a player is standing inside territory claimed by a neutral or enemy faction, all of that faction's nearby claims will be shown on the faction map regardless. --- src/com/massivecraft/factions/Board.java | 15 +++++++++++++-- src/com/massivecraft/factions/Conf.java | 2 ++ .../massivecraft/factions/struct/Relation.java | 10 +++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/com/massivecraft/factions/Board.java b/src/com/massivecraft/factions/Board.java index cb1b31b3..2d037619 100644 --- a/src/com/massivecraft/factions/Board.java +++ b/src/com/massivecraft/factions/Board.java @@ -17,6 +17,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; +import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.util.AsciiCompass; import com.massivecraft.factions.util.DiscUtil; import com.massivecraft.factions.util.TextUtil; @@ -161,7 +162,8 @@ public class Board { */ public static ArrayList getMap(Faction faction, FLocation flocation, double inDegrees) { ArrayList ret = new ArrayList(); - ret.add(TextUtil.titleize("("+flocation.getCoordString()+") "+getFactionAt(flocation).getTag(faction))); + Faction factionLoc = getFactionAt(flocation); + ret.add(TextUtil.titleize("("+flocation.getCoordString()+") "+factionLoc.getTag(faction))); int halfWidth = Conf.mapWidth / 2; int halfHeight = Conf.mapHeight / 2; @@ -186,17 +188,26 @@ public class Board { } else { FLocation flocationHere = topLeft.getRelative(dx, dz); Faction factionHere = getFactionAt(flocationHere); + Relation relation = faction.getRelation(factionHere); if (factionHere.isNone()) { row += ChatColor.GRAY+"-"; } else if (factionHere.isSafeZone()) { row += ChatColor.GOLD+"+"; } else if (factionHere.isWarZone()) { row += ChatColor.DARK_RED+"+"; - } else { + } else if ( + factionHere == faction + || factionHere == factionLoc + || relation.isAtLeast(Relation.ALLY) + || (Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL)) + || (Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY)) + ) { if (!fList.containsKey(factionHere.getTag())) fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]); char tag = fList.get(factionHere.getTag()); row += factionHere.getRelation(faction).getColor() + "" + tag; + } else { + row += ChatColor.GRAY+"-"; } } } diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index 1bd773aa..f510b31d 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -40,6 +40,8 @@ public class Conf { public static boolean newFactionsDefaultOpen = true; public static boolean showMapFactionKey = true; + public static boolean showNeutralFactionsOnMap = true; + public static boolean showEnemyFactionsOnMap = true; // Disallow joining/leaving/kicking while power is negative public static boolean CanLeaveWithNegativePower = true; diff --git a/src/com/massivecraft/factions/struct/Relation.java b/src/com/massivecraft/factions/struct/Relation.java index 25866850..94fdc5aa 100644 --- a/src/com/massivecraft/factions/struct/Relation.java +++ b/src/com/massivecraft/factions/struct/Relation.java @@ -40,6 +40,14 @@ public enum Relation { return this == Relation.ENEMY; } + public boolean isAtLeast(Relation relation) { + return this.value >= relation.value; + } + + public boolean isAtMost(Relation relation) { + return this.value <= relation.value; + } + public ChatColor getColor() { if (this == Relation.MEMBER) { return Conf.colorMember; @@ -47,7 +55,7 @@ public enum Relation { return Conf.colorAlly; } else if (this == Relation.NEUTRAL) { return Conf.colorNeutral; - } else { //if (relation == FactionRelation.ENEMY) { + } else { return Conf.colorEnemy; } }