From a783dc33cf076c76e515ab7dd1e3c9a839bf6c0e Mon Sep 17 00:00:00 2001 From: Brettflan Date: Tue, 6 Nov 2012 10:06:37 -0600 Subject: [PATCH] Protect hanging entities (paintings and item frames) from explosions; thanks to Tahkeh for the method --- .../factions/listeners/FactionsEntityListener.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index 5b4ec8a4..3c83087d 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -31,6 +31,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; @@ -367,7 +368,17 @@ public class FactionsEntityListener implements Listener public void onPaintingBreak(HangingBreakEvent event) { if (event.isCancelled()) return; - + + if (event.getCause() == RemoveCause.EXPLOSION) + { + Faction faction = Board.getFactionAt(new FLocation(event.getEntity().getLocation())); + if (faction.getFlag(FFlag.EXPLOSIONS) == false) + { // faction has explosions disabled + event.setCancelled(true); + return; + } + } + if (! (event instanceof HangingBreakByEntityEvent)) { return;