Citizen NPCs are not island visitors so do not protect them.

https://github.com/BentoBoxWorld/BentoBox/issues/1518
This commit is contained in:
tastybento 2020-09-18 13:45:39 -07:00
parent 5a5435d815
commit 4609881542
2 changed files with 9 additions and 0 deletions

View File

@ -103,6 +103,7 @@ public class InvincibleVisitorsListener extends FlagListener implements ClickHan
World world = e.getEntity().getWorld();
if (!(e.getEntity() instanceof Player)
|| !getIWM().inWorld(world)
|| e.getEntity().hasMetadata("NPC")
|| !getIWM().getIvSettings(world).contains(e.getCause().name())
|| getIslands().userIsOnIsland(world, User.getInstance(e.getEntity()))) {
return;

View File

@ -255,6 +255,14 @@ public class InvincibleVisitorsListenerTest {
assertTrue(e.isCancelled());
verify(player, never()).setGameMode(eq(GameMode.SPECTATOR));
}
@Test
public void testOnVisitorGetDamageNPC() {
when(player.hasMetadata(eq("NPC"))).thenReturn(true);
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
listener.onVisitorGetDamage(e);
assertFalse(e.isCancelled());
}
@Test