From d793b718aa3135348a5e4e2c6823fdc72684048a Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Sat, 4 Jun 2011 16:59:11 +0800 Subject: [PATCH 1/5] Removed unused import and unused private variable "lock" Change-Id: I6356e9cbcdfef78639d2571c39ae6c9ff9415bab --- src/org/mcteam/factions/Factions.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/org/mcteam/factions/Factions.java b/src/org/mcteam/factions/Factions.java index ff09ef12..ab6b11e6 100644 --- a/src/org/mcteam/factions/Factions.java +++ b/src/org/mcteam/factions/Factions.java @@ -24,7 +24,6 @@ import org.mcteam.factions.gson.GsonBuilder; import org.mcteam.factions.listeners.FactionsBlockListener; import org.mcteam.factions.listeners.FactionsEntityListener; import org.mcteam.factions.listeners.FactionsPlayerListener; -import org.mcteam.factions.util.MiscUtil; import com.nijiko.permissions.PermissionHandler; @@ -57,8 +56,6 @@ public class Factions extends JavaPlugin { private String baseCommand; - private static boolean lock = false; - public Factions() { Factions.instance = this; } From 24a4da6d2e7ba0ff07109cfc4fd75e0b36a71bc1 Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Sat, 4 Jun 2011 17:36:03 +0800 Subject: [PATCH 2/5] Added configs for protection for offline factions Change-Id: I2351b74144195d7b068b65b218732fdbd0fc3bef --- src/org/mcteam/factions/Conf.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/org/mcteam/factions/Conf.java b/src/org/mcteam/factions/Conf.java index 674c5663..8f2884e1 100644 --- a/src/org/mcteam/factions/Conf.java +++ b/src/org/mcteam/factions/Conf.java @@ -90,6 +90,8 @@ public class Conf { public static Set territoryProtectedMaterials = new HashSet(); public static Set territoryDenyUseageMaterials = new HashSet(); + public static Set territoryProtectedMaterialsWhenOffline = new HashSet(); + public static Set territoryDenyUseageMaterialsWhenOffline = new HashSet(); public static transient Set safeZoneNerfedCreatureTypes = new HashSet(); @@ -111,6 +113,17 @@ public class Conf { territoryDenyUseageMaterials.add(Material.BUCKET); territoryDenyUseageMaterials.add(Material.WATER_BUCKET); territoryDenyUseageMaterials.add(Material.LAVA_BUCKET); + + territoryProtectedMaterialsWhenOffline.add(Material.WOODEN_DOOR); + territoryProtectedMaterialsWhenOffline.add(Material.TRAP_DOOR); + territoryProtectedMaterialsWhenOffline.add(Material.DISPENSER); + territoryProtectedMaterialsWhenOffline.add(Material.CHEST); + territoryProtectedMaterialsWhenOffline.add(Material.FURNACE); + + territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); + territoryDenyUseageMaterialsWhenOffline.add(Material.BUCKET); + territoryDenyUseageMaterialsWhenOffline.add(Material.WATER_BUCKET); + territoryDenyUseageMaterialsWhenOffline.add(Material.LAVA_BUCKET); safeZoneNerfedCreatureTypes.add(CreatureType.CREEPER); safeZoneNerfedCreatureTypes.add(CreatureType.GHAST); From 5ddc24f8559fbd4f40d5b594550baf6f7134b83c Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Sat, 4 Jun 2011 17:36:28 +0800 Subject: [PATCH 3/5] Added offline protection using the new configs Change-Id: I93c5122bce09a3bd760fcd18d4dd0801a3548af9 --- .../factions/listeners/FactionsPlayerListener.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java index 1e1ad765..223c09ee 100644 --- a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java +++ b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java @@ -202,12 +202,18 @@ public class FactionsPlayerListener extends PlayerListener{ return true; } - if ( ! Conf.territoryDenyUseageMaterials.contains(material)) { - return true; // Item isn't one we're preventing. - } - Faction otherFaction = Board.getFactionAt(new FLocation(block)); + if (otherFaction.getOnlinePlayers()!=null){ + if ( ! Conf.territoryDenyUseageMaterials.contains(material)) { + return true; // Item isn't one we're preventing for online factions. + } + }else{ + if ( ! Conf.territoryDenyUseageMaterialsWhenOffline.contains(material)) { + return true; // Item isn't one we're preventing for offline factions. + } + } + FPlayer me = FPlayer.get(player); if (otherFaction.isNone()) { From 999be49f5cae444293b1c863c3eef40718cc6882 Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Sat, 4 Jun 2011 17:59:35 +0800 Subject: [PATCH 4/5] Forgot offline block protection. Added now. Change-Id: Ib4e8866e5da655e01bdbb64f61d2130c664bc241 --- .../factions/listeners/FactionsPlayerListener.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java index 223c09ee..bd60d9a0 100644 --- a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java +++ b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java @@ -258,14 +258,21 @@ public class FactionsPlayerListener extends PlayerListener{ Material material = block.getType(); + Faction otherFaction = Board.getFactionAt(new FLocation(block)); + // We only care about some material types. - if ( ! Conf.territoryProtectedMaterials.contains(material)) { - return true; + if (otherFaction.getOnlinePlayers()!=null){ + if ( ! Conf.territoryProtectedMaterials.contains(material)) { + return true; + } + }else{ + if ( ! Conf.territoryProtectedMaterialsWhenOffline.contains(material)) { + return true; + } } FPlayer me = FPlayer.get(player); Faction myFaction = me.getFaction(); - Faction otherFaction = Board.getFactionAt(new FLocation(block)); // In safe zones you may use any block... if (otherFaction.isNormal() && myFaction != otherFaction) { From a1e89457fff41a5c8979002b0a96cfdd883a3f53 Mon Sep 17 00:00:00 2001 From: Thomas Tan Date: Sat, 4 Jun 2011 18:14:39 +0800 Subject: [PATCH 5/5] Change-Id: Ibaa6d8c7eba4fe616faa5e78d946c9495d252fde --- src/org/mcteam/factions/listeners/FactionsPlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java index bd60d9a0..cc850056 100644 --- a/src/org/mcteam/factions/listeners/FactionsPlayerListener.java +++ b/src/org/mcteam/factions/listeners/FactionsPlayerListener.java @@ -265,7 +265,7 @@ public class FactionsPlayerListener extends PlayerListener{ if ( ! Conf.territoryProtectedMaterials.contains(material)) { return true; } - }else{ + } else { if ( ! Conf.territoryProtectedMaterialsWhenOffline.contains(material)) { return true; }