Fixes potion splash pvp check (#1230)

Before this change, the entire potion splash would be cancelled if a single protected player would have been affected. Now, it will only remove the protected players themselves from the affected list.
This commit is contained in:
Nassim 2020-03-18 08:36:03 +01:00 committed by GitHub
parent c57b56f1f0
commit 706bed62ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,8 +136,12 @@ public class PVPListener extends FlagListener {
public void onSplashPotionSplash(final PotionSplashEvent e) {
if (e.getEntity().getShooter() instanceof Player && getPlugin().getIWM().inWorld(e.getEntity().getWorld())) {
User user = User.getInstance((Player)e.getEntity().getShooter());
// Run through affected entities and cancel the splash if any are a protected player
e.setCancelled(e.getAffectedEntities().stream().anyMatch(le -> blockPVP(user, le, e, getFlag(e.getEntity().getWorld()))));
// Run through affected entities and cancel the splash for protected players
for (LivingEntity le : e.getAffectedEntities()) {
if (!le.getUniqueId().equals(user.getUniqueId()) && blockPVP(user, le, e, getFlag(e.getEntity().getWorld()))) {
e.setIntensity(le, 0);
}
}
}
}