diff options
author | GunfighterJ <joseph.jenniges@gmail.com> | 2013-02-25 17:15:20 -0600 |
---|---|---|
committer | GunfighterJ <joseph.jenniges@gmail.com> | 2013-02-25 17:15:20 -0600 |
commit | d5f702f2cba892321e0cb1dcedd27d5ea56244d8 (patch) | |
tree | e74b1e126281cd3dfc5c918e79dfc9cb197f02b7 /EssentialsProtect/src/com/earth2me/essentials/protect | |
parent | 964bdc6d30748d843c8e510758d69838f8d29791 (diff) | |
download | Essentials-d5f702f2cba892321e0cb1dcedd27d5ea56244d8.tar Essentials-d5f702f2cba892321e0cb1dcedd27d5ea56244d8.tar.gz Essentials-d5f702f2cba892321e0cb1dcedd27d5ea56244d8.tar.lz Essentials-d5f702f2cba892321e0cb1dcedd27d5ea56244d8.tar.xz Essentials-d5f702f2cba892321e0cb1dcedd27d5ea56244d8.zip |
[Protect] Prevent creepers from breaking paintings if their explosions are disabled.
Backport from 3.0
Diffstat (limited to 'EssentialsProtect/src/com/earth2me/essentials/protect')
-rw-r--r-- | EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java index d9102c023..4ba608d48 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java @@ -13,6 +13,8 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
+import org.bukkit.event.hanging.HangingBreakEvent;
public class EssentialsProtectEntityListener implements Listener
@@ -176,7 +178,7 @@ public class EssentialsProtectEntityListener implements Listener private boolean shouldBeDamaged(final User user, final String type)
{
return (user.isAuthorized("essentials.protect.damage.".concat(type))
- && !user.isAuthorized("essentials.protect.damage.disable"));
+ && !user.isAuthorized("essentials.protect.damage.disable"));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -232,7 +234,7 @@ public class EssentialsProtectEntityListener implements Listener event.setCancelled(true);
return;
}
-
+
// This code will prevent explosions near protected rails, signs or protected chests
// TODO: Use protect db instead of this code
@@ -332,4 +334,15 @@ public class EssentialsProtectEntityListener implements Listener event.setCancelled(true);
}
}
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onPaintingBreak(HangingBreakByEntityEvent event)
+ {
+ if (event.getCause() == HangingBreakEvent.RemoveCause.ENTITY
+ && event.getRemover() instanceof Creeper
+ && prot.getSettingBool(ProtectConfig.prevent_creeper_explosion))
+ {
+ event.setCancelled(true);
+ }
+ }
}
|