From 94d1dc210c1718eef63d6fce33fee1c5a174e680 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Thu, 30 Jun 2011 06:13:47 -0500 Subject: [PATCH] When you have the "claimsMustBeConnected" option enabled, it now works on a world-by-world basis, so if you have claims in one world you can still make claims in other worlds --- src/org/mcteam/factions/Board.java | 13 +++++++++++++ src/org/mcteam/factions/FPlayer.java | 2 +- src/org/mcteam/factions/Faction.java | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/org/mcteam/factions/Board.java b/src/org/mcteam/factions/Board.java index 0b5cc611..f36713e2 100644 --- a/src/org/mcteam/factions/Board.java +++ b/src/org/mcteam/factions/Board.java @@ -120,6 +120,19 @@ public class Board { return getFactionCoordCount(faction.getId()); } + public static int getFactionCoordCountInWorld(Faction faction, String worldName) { + int factionId = faction.getId(); + int ret = 0; + Iterator> iter = flocationIds.entrySet().iterator(); + while (iter.hasNext()) { + Entry entry = iter.next(); + if (entry.getValue() == factionId && entry.getKey().getWorldName().equals(worldName)) { + ret += 1; + } + } + return ret; + } + //----------------------------------------------// // Map generation //----------------------------------------------// diff --git a/src/org/mcteam/factions/FPlayer.java b/src/org/mcteam/factions/FPlayer.java index f9588161..6f69289b 100644 --- a/src/org/mcteam/factions/FPlayer.java +++ b/src/org/mcteam/factions/FPlayer.java @@ -506,7 +506,7 @@ public class FPlayer { return false; } - if (Conf.claimsMustBeConnected && myFaction.getLandRounded() > 0 && !Board.isConnectedLocation(flocation, myFaction)) { + if (Conf.claimsMustBeConnected && myFaction.getLandRoundedInWorld(flocation.getWorldName()) > 0 && !Board.isConnectedLocation(flocation, myFaction)) { sendMessage("You can only claim additional land which is connected to your first claim!"); return false; } diff --git a/src/org/mcteam/factions/Faction.java b/src/org/mcteam/factions/Faction.java index a8229c99..23e034cb 100644 --- a/src/org/mcteam/factions/Faction.java +++ b/src/org/mcteam/factions/Faction.java @@ -225,6 +225,10 @@ public class Faction { return Board.getFactionCoordCount(this); } + public int getLandRoundedInWorld(String worldName) { + return Board.getFactionCoordCountInWorld(this, worldName); + } + public boolean hasLandInflation() { return this.getLandRounded() > this.getPowerRounded(); }