From 67e9d9c5356918f8f84752f622e0dacc8f2809df Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 12 Oct 2013 03:30:10 +0200 Subject: [PATCH] Fishing TNT traps should not destroy blocks --- .../gmail/nossr50/listeners/EntityListener.java | 16 ++++++++++++++++ src/main/java/com/gmail/nossr50/mcMMO.java | 1 + .../nossr50/skills/fishing/FishingManager.java | 1 + 3 files changed, 18 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 737790cf8..c9562dedd 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -459,6 +459,22 @@ public class EntityListener implements Listener { } } + /** + * Monitor EntityExplode events. + * + * @param event The event to monitor + */ + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onEnitityExplodeMonitor(EntityExplodeEvent event) { + Entity entity = event.getEntity(); + + if (!entity.hasMetadata(mcMMO.tntsafeMetadataKey)) { + return; + } + + event.blockList().clear(); + } + /** * Handle FoodLevelChange events that involve modifying the event. * diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 547e093bf..a1940001f 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -91,6 +91,7 @@ public class mcMMO extends JavaPlugin { public final static String blockMetadataKey = "mcMMO: Piston Tracking"; public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace"; public final static String tntMetadataKey = "mcMMO: Tracked TNT"; + public final static String tntsafeMetadataKey = "mcMMO: Safe TNT"; public final static String customNameKey = "mcMMO: Custom Name"; public final static String customVisibleKey = "mcMMO: Name Visibility"; public final static String droppedItemKey = "mcMMO: Tracked Item"; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 08edbb967..ec8b9616a 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -499,6 +499,7 @@ public class FishingManager extends SkillManager { double magnitude = velocity.length(); fishingCatch.setVelocity(velocity.multiply((magnitude + 1) / magnitude)); + tnt.setMetadata(mcMMO.tntsafeMetadataKey, mcMMO.metadataValue); tnt.setFuseTicks(3 * Misc.TICK_CONVERSION_FACTOR); } else {