From 8880d503e221bcce0f79deeb86db3cf4f7d0bcfa Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 20 Jun 2011 21:15:41 -0500 Subject: [PATCH] added option "claimsMustBeConnected" (defaults to false) which requires all faction claims beyond the first to be connected to each other; support for "{FACTION_TITLE}" in chat messages --- src/org/mcteam/factions/Board.java | 9 +++++++++ src/org/mcteam/factions/Conf.java | 6 ++++-- src/org/mcteam/factions/FPlayer.java | 5 +++++ .../factions/listeners/FactionsPlayerListener.java | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/org/mcteam/factions/Board.java b/src/org/mcteam/factions/Board.java index ae195e09..0b5cc611 100644 --- a/src/org/mcteam/factions/Board.java +++ b/src/org/mcteam/factions/Board.java @@ -76,6 +76,15 @@ public class Board { FLocation d = flocation.getRelative(0, -1); return faction != getFactionAt(a) || faction != getFactionAt(b) || faction != getFactionAt(c) || faction != getFactionAt(d); } + + // Is this coord connected to any coord claimed by the specified faction? + public static boolean isConnectedLocation(FLocation flocation, Faction faction) { + FLocation a = flocation.getRelative(1, 0); + FLocation b = flocation.getRelative(-1, 0); + FLocation c = flocation.getRelative(0, 1); + FLocation d = flocation.getRelative(0, -1); + return faction == getFactionAt(a) || faction == getFactionAt(b) || faction == getFactionAt(c) || faction == getFactionAt(d); + } //----------------------------------------------// diff --git a/src/org/mcteam/factions/Conf.java b/src/org/mcteam/factions/Conf.java index c24ec42f..6ff36dd5 100644 --- a/src/org/mcteam/factions/Conf.java +++ b/src/org/mcteam/factions/Conf.java @@ -65,9 +65,11 @@ public class Conf { public static boolean homesTeleportToOnDeath = true; public static boolean homesTeleportAllowedFromEnemyTerritory = true; public static double homesTeleportAllowedEnemyDistance = 32; - + public static boolean disablePVPForFactionlessPlayers = false; - + + public static boolean claimsMustBeConnected = false; + public static double territoryShieldFactor = 0.3; public static boolean territoryDenyBuild = true; public static boolean territoryDenyBuildWhenOffline = true; diff --git a/src/org/mcteam/factions/FPlayer.java b/src/org/mcteam/factions/FPlayer.java index 6b29c06b..a32a28be 100644 --- a/src/org/mcteam/factions/FPlayer.java +++ b/src/org/mcteam/factions/FPlayer.java @@ -487,6 +487,11 @@ public class FPlayer { return false; } + if (Conf.claimsMustBeConnected && !Board.isConnectedLocation(flocation, myFaction)) { + sendMessage("You can only claim additional land which is connected to your first claim!"); + return false; + } + if (otherFaction.isNone()) { myFaction.sendMessage(this.getNameAndRelevant(myFaction)+Conf.colorSystem+" claimed some new land :D"); } else { //if (otherFaction.isNormal()) { diff --git a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java index 0c4f73c6..9416634a 100644 --- a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java +++ b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java @@ -73,6 +73,10 @@ public class FactionsPlayerListener extends PlayerListener{ if (!Conf.chatTagReplaceString.isEmpty() && eventFormat.contains(Conf.chatTagReplaceString)) { // we're using the "replace" method of inserting the faction tags + // if they stuck "{FACTION_TITLE}" in there, go ahead and do it too + if (eventFormat.contains("{FACTION_TITLE}")) { + eventFormat = eventFormat.replace("{FACTION_TITLE}", me.getTitle()); + } InsertIndex = eventFormat.indexOf(Conf.chatTagReplaceString); eventFormat = eventFormat.replace(Conf.chatTagReplaceString, ""); Conf.chatTagPadAfter = false;