Skip to content

Commit

Permalink
Fixes potion splash pvp check (#1230)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kennytv authored Mar 18, 2020
1 parent c57b56f commit 706bed6
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ public void onFishing(PlayerFishEvent e) {
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);
}
}
}
}

Expand Down

0 comments on commit 706bed6

Please sign in to comment.