mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Fix: player is no longer immune to projectiles shot by themselves (#4856)
This commit is contained in:
parent
965540dfaf
commit
08b08b1285
@ -362,40 +362,30 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
//Friendly fire checks
|
//Friendly fire checks
|
||||||
if (defender instanceof Player defendingPlayer) {
|
if (defender instanceof Player defendingPlayer) {
|
||||||
Player attackingPlayer;
|
|
||||||
|
|
||||||
//If the attacker is a Player or a projectile belonging to a player
|
//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(attacker instanceof Projectile projectile) {
|
if(projectile.getShooter() instanceof Player attackingPlayer && !attackingPlayer.equals(defendingPlayer)) {
|
||||||
if(((Projectile) attacker).getShooter() instanceof Player) {
|
//Check for party friendly fire and cancel the event
|
||||||
attackingPlayer = (Player) projectile.getShooter();
|
if (checkParties(event, defendingPlayer, attackingPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Check for party friendly fire and cancel the event
|
//Deflect checks
|
||||||
if (checkParties(event, defendingPlayer, attackingPlayer))
|
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
|
||||||
{
|
if (mcMMOPlayer != null) {
|
||||||
|
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||||
|
|
||||||
|
if (unarmedManager.canDeflect()) {
|
||||||
|
if (projectile instanceof Arrow && unarmedManager.deflectCheck()) {
|
||||||
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Deflect checks
|
|
||||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(defendingPlayer);
|
|
||||||
if (mcMMOPlayer != null) {
|
|
||||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
|
||||||
|
|
||||||
if (unarmedManager.canDeflect()) {
|
|
||||||
if (projectile instanceof Arrow && unarmedManager.deflectCheck()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attackingPlayer = (Player) attacker;
|
|
||||||
//Check for party friendly fire and cancel the event
|
|
||||||
if (checkParties(event, defendingPlayer, attackingPlayer))
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} else if (attacker instanceof Player attackingPlayer){
|
||||||
|
if (checkParties(event, defendingPlayer, attackingPlayer))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user