Skip to content

Commit

Permalink
Judge location of damage by location of entity not user
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Jul 9, 2023
1 parent 211d636 commit 170c31f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ else if (Util.isHostileEntity(e.getEntity()))
private void respond(EntityDamageByEntityEvent e, Entity damager, Flag flag) {
// Get the attacker
if (damager instanceof Player player) {
checkIsland(e, player, player.getLocation(), flag);
checkIsland(e, player, e.getEntity().getLocation(), flag);
} else if (damager instanceof Projectile p && // Find out who fired the projectile
p.getShooter() instanceof Player player && !checkIsland(e, player, player.getLocation(), flag)) {
p.getShooter() instanceof Player player && !checkIsland(e, player, e.getEntity().getLocation(), flag)) {
e.getEntity().setFireTicks(0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -93,7 +92,7 @@ public void testOnEntityDamagePlayeronMonster() {
HurtingListener hl = new HurtingListener();
hl.onEntityDamage(e);
assertTrue(e.isCancelled());
verify(notifier).notify(eq(user), eq("protection.protected"));
verify(notifier).notify(user, "protection.protected");
}

/**
Expand All @@ -106,7 +105,7 @@ public void testOnEntityDamagePlayeronMonsterOp() {
HurtingListener hl = new HurtingListener();
hl.onEntityDamage(e);
assertFalse(e.isCancelled());
verify(notifier, never()).notify(eq(user), eq("protection.protected"));
verify(notifier, never()).notify(user, "protection.protected");
}

/**
Expand All @@ -121,7 +120,7 @@ public void testOnFishingDisallowArmorStandCatching() {
HurtingListener hl = new HurtingListener();
hl.onFishing(e);
// Verify
verify(notifier).notify(eq(user), eq("protection.protected"));
verify(notifier).notify(user, "protection.protected");
}

/**
Expand All @@ -138,7 +137,7 @@ public void testOnFishingAllowArmorStandCatching() {
when(island.isAllowed(any(), any())).thenReturn(true);
hl.onFishing(e);
// Verify
verify(notifier, never()).notify(eq(user), eq("protection.protected"));
verify(notifier, never()).notify(user, "protection.protected");
}

/**
Expand All @@ -153,7 +152,7 @@ public void testOnFishingDisallowAnimalCatching() {
HurtingListener hl = new HurtingListener();
hl.onFishing(e);
// Verify
verify(notifier).notify(eq(user), eq("protection.protected"));
verify(notifier).notify(user, "protection.protected");
}

/**
Expand All @@ -170,7 +169,7 @@ public void testOnFishingAllowAnimalsCatching() {
when(island.isAllowed(any(), any())).thenReturn(true);
hl.onFishing(e);
// Verify
verify(notifier, never()).notify(eq(user), eq("protection.protected"));
verify(notifier, never()).notify(user, "protection.protected");
}

/**
Expand All @@ -185,7 +184,7 @@ public void testOnFishingDisallowMonsterCatching() {
HurtingListener hl = new HurtingListener();
hl.onFishing(e);
// Verify
verify(notifier).notify(eq(user), eq("protection.protected"));
verify(notifier).notify(user, "protection.protected");
}

/**
Expand All @@ -202,7 +201,7 @@ public void testOnFishingAllowMonsterCatching() {
when(island.isAllowed(any(), any())).thenReturn(true);
hl.onFishing(e);
// Verify
verify(notifier, never()).notify(eq(user), eq("protection.protected"));
verify(notifier, never()).notify(user, "protection.protected");
}

/**
Expand All @@ -218,7 +217,7 @@ public void testOnFishingDisallowVillagerCatching() {
HurtingListener hl = new HurtingListener();
hl.onFishing(e);
// Verify
verify(notifier).notify(eq(user), eq("protection.protected"));
verify(notifier).notify(user, "protection.protected");
}

/**
Expand All @@ -234,7 +233,7 @@ public void testOnFishingDisallowWanderingTraderCatching() {
HurtingListener hl = new HurtingListener();
hl.onFishing(e);
// Verify
verify(notifier).notify(eq(user), eq("protection.protected"));
verify(notifier).notify(user, "protection.protected");
}


Expand All @@ -253,7 +252,7 @@ public void testOnFishingAllowVillagerCatching() {
when(island.isAllowed(any(), any())).thenReturn(true);
hl.onFishing(e);
// Verify
verify(notifier, never()).notify(eq(user), eq("protection.protected"));
verify(notifier, never()).notify(user, "protection.protected");
}

/**
Expand All @@ -271,7 +270,7 @@ public void testOnFishingAllowWanderingTraderCatching() {
when(island.isAllowed(any(), any())).thenReturn(true);
hl.onFishing(e);
// Verify
verify(notifier, never()).notify(eq(user), eq("protection.protected"));
verify(notifier, never()).notify(user, "protection.protected");
}

/**
Expand Down

0 comments on commit 170c31f

Please sign in to comment.