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
This commit is contained in:
Andreas Troelsen
2021-12-05 17:30:24 +01:00
parent c80f0375ee
commit 9164b125bd
3 changed files with 29 additions and 2 deletions
@@ -1400,6 +1400,7 @@ public class ArenaImpl implements Arena
case ARROW:
case MINECART:
case BOAT:
case PRIMED_TNT:
case SHULKER_BULLET:
e.remove();
}
@@ -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) {