From 9164b125bdd84d8ad9acea99c43dd9d1bf00dec8 Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Sun, 5 Dec 2021 16:52:39 +0100 Subject: [PATCH] Allow flaming arrows to ignite TNT. It turns out that, according to the Spigot API, flaming arrows actually _change_ TNT blocks to air before/instead of igniting them. While this is a little counter-intuitive, the fix seems to revolve around allowing the change to happen if the changed block is TNT and the "changer" is an arrow. Allowing the change event to happen means "foreign" primed TNT entities will spawn, which makes it necessary to clean them up during the session cleanup phase in ArenaImpl. Fixes #696 --- changelog.md | 1 + .../com/garbagemule/MobArena/ArenaImpl.java | 1 + .../garbagemule/MobArena/ArenaListener.java | 29 +++++++++++++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 5e94739..d998fd0 100644 --- a/changelog.md +++ b/changelog.md @@ -33,6 +33,7 @@ These changes will (most likely) be included in the next version. - The title-based announcer and the title-based boss health bar have been fixed to work with the breaking change to the Title API in Spigot 1.17. - Arena Signs now correctly update for arenas that don't have `kebab-case` names in the config-file. - Block explosion events cancelled by other plugins now remain cancelled unless MobArena specifically uncancels them for an arena. +- Flaming arrows now ignite TNT blocks in the arena. ## [0.106] - 2021-05-09 ### Added diff --git a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java index 587002d..7697b71 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java @@ -1400,6 +1400,7 @@ public class ArenaImpl implements Arena case ARROW: case MINECART: case BOAT: + case PRIMED_TNT: case SHULKER_BULLET: e.remove(); } diff --git a/src/main/java/com/garbagemule/MobArena/ArenaListener.java b/src/main/java/com/garbagemule/MobArena/ArenaListener.java index ecf5a08..c0da4ad 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaListener.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaListener.java @@ -30,6 +30,7 @@ import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Horse; @@ -952,8 +953,32 @@ public class ArenaListener } public void onEntityChangeBlock(EntityChangeBlockEvent event) { - if (arena.getRegion().contains(event.getBlock().getLocation())) - event.setCancelled(true); + if (!protect) { + return; + } + + Block block = event.getBlock(); + if (!arena.getRegion().contains(block.getLocation())) { + return; + } + + if (arena.isRunning()) { + if (block.getType() == Material.TNT) { + Entity entity = event.getEntity(); + if (entity instanceof Arrow) { + Arrow arrow = (Arrow) entity; + ProjectileSource shooter = arrow.getShooter(); + if (shooter instanceof Player) { + Player player = (Player) shooter; + if (arena.inArena(player)) { + return; + } + } + } + } + } + + event.setCancelled(true); } public void onEntityRegainHealth(EntityRegainHealthEvent event) {