Fix: player is no longer immune to projectiles shot by themselves (#4856)

This commit is contained in:
nopeless 2023-01-28 13:57:31 -06:00 committed by GitHub
parent 965540dfaf
commit 08b08b1285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -362,20 +362,13 @@ public class EntityListener implements Listener {
//Friendly fire checks
if (defender instanceof Player defendingPlayer) {
Player attackingPlayer;
//If the attacker is a Player or a projectile belonging to a player
if(attacker instanceof Projectile || attacker instanceof Player) {
if(attacker instanceof Projectile projectile) {
if(((Projectile) attacker).getShooter() instanceof Player) {
attackingPlayer = (Player) projectile.getShooter();
if(projectile.getShooter() instanceof Player attackingPlayer && !attackingPlayer.equals(defendingPlayer)) {
//Check for party friendly fire and cancel the event
if (checkParties(event, defendingPlayer, attackingPlayer))
{
if (checkParties(event, defendingPlayer, attackingPlayer)) {
return;
}
}
//Deflect checks
@ -390,14 +383,11 @@ public class EntityListener implements Listener {
}
}
}
} else {
attackingPlayer = (Player) attacker;
//Check for party friendly fire and cancel the event
} else if (attacker instanceof Player attackingPlayer){
if (checkParties(event, defendingPlayer, attackingPlayer))
return;
}
}
}
//Required setup for processCombatAttack
if(attacker instanceof Projectile) {