Cancel damage to players by pets.

This is technically not necessary when pets are simple entities like
wolves and zombies, because these types of pets will never target and
thus attack other players in the arena. However, projectile entities
such as Blazes and Ghasts may hit players in the line of fire, and so
any such damage should be cancelled.

Fixes #712
This commit is contained in:
Andreas Troelsen
2022-02-12 17:55:58 +01:00
parent d5ea15fa08
commit 77b2525707
2 changed files with 7 additions and 0 deletions
@@ -731,6 +731,12 @@ public class ArenaListener
}
if (arena.inArena(player)) {
// Cancel damage from pets (and their projectiles)
if (monsters.hasPet(damager)) {
event.setCancelled(true);
return;
}
// Cancel PvP damage if disabled
if (!pvpEnabled && damager instanceof Player && !damager.equals(player)) {
event.setCancelled(true);