From dce2e7d2665675bbc8aee9ce4a4aa1862dcf1427 Mon Sep 17 00:00:00 2001 From: John Veres Date: Sat, 3 Nov 2012 07:21:28 -0400 Subject: [PATCH] Added config protection defaults for Beacon and Anvil. Added Hanging protection for explosions. --- src/com/massivecraft/factions/Conf.java | 4 ++ .../listeners/FactionsEntityListener.java | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index b901810c..e4e330bc 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -309,6 +309,8 @@ public class Conf territoryProtectedMaterials.add(Material.ENCHANTMENT_TABLE); territoryProtectedMaterials.add(Material.CAULDRON); territoryProtectedMaterials.add(Material.SOIL); + territoryProtectedMaterials.add(Material.BEACON); + territoryProtectedMaterials.add(Material.ANVIL); territoryDenyUseageMaterials.add(Material.FIREBALL); territoryDenyUseageMaterials.add(Material.FLINT_AND_STEEL); @@ -330,6 +332,8 @@ public class Conf territoryProtectedMaterialsWhenOffline.add(Material.ENCHANTMENT_TABLE); territoryProtectedMaterialsWhenOffline.add(Material.CAULDRON); territoryProtectedMaterialsWhenOffline.add(Material.SOIL); + territoryProtectedMaterialsWhenOffline.add(Material.BEACON); + territoryProtectedMaterialsWhenOffline.add(Material.ANVIL); territoryDenyUseageMaterialsWhenOffline.add(Material.FIREBALL); territoryDenyUseageMaterialsWhenOffline.add(Material.FLINT_AND_STEEL); diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index 56b01222..4209b6bd 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -34,6 +34,7 @@ import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.PotionSplashEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause; import org.bukkit.event.hanging.HangingPlaceEvent; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -487,6 +488,62 @@ public class FactionsEntityListener implements Listener public void onPaintingBreak(HangingBreakEvent event) { if (event.isCancelled()) return; + if (event.getCause() == RemoveCause.EXPLOSION) + { + Location loc = event.getEntity().getLocation(); + Faction faction = Board.getFactionAt(new FLocation(loc)); + if (faction.noExplosionsInTerritory()) + { + // faction is peaceful and has explosions set to disabled + event.setCancelled(true); + return; + } + + boolean online = faction.hasPlayersOnline(); + + if + ( + (faction.isNone() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) + || + (faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline)) + || + (faction.isWarZone() && Conf.warZoneBlockCreepers) + || + faction.isSafeZone() + ) + { + // creeper which needs prevention + event.setCancelled(true); + } + else if + ( + (faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) + || + (faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) + || + (faction.isWarZone() && Conf.warZoneBlockFireballs) + || + faction.isSafeZone() + ) + { + // ghast fireball which needs prevention + event.setCancelled(true); + } + else if + ( + (faction.isNone() && Conf.wildernessBlockTNT && ! Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) + || + (faction.isNormal() && ( online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline )) + || + (faction.isWarZone() && Conf.warZoneBlockTNT) + || + (faction.isSafeZone() && Conf.safeZoneBlockTNT) + ) + { + // TNT which needs prevention + event.setCancelled(true); + } + } if (! (event instanceof HangingBreakByEntityEvent)) {