use of org.bukkit.event.entity.EntityDamageEvent in project BentoBox by BentoBoxWorld.
the class InvincibleVisitorsListenerTest method testOnVisitorGetDamageNotVisitor.
@Test
public void testOnVisitorGetDamageNotVisitor() {
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
when(im.userIsOnIsland(any(), any())).thenReturn(true);
listener.onVisitorGetDamage(e);
assertFalse(e.isCancelled());
}
use of org.bukkit.event.entity.EntityDamageEvent in project BentoBox by BentoBoxWorld.
the class InvincibleVisitorsListenerTest method testOnVisitorGetDamageNotInWorld.
@Test
public void testOnVisitorGetDamageNotInWorld() {
when(iwm.inWorld(any(World.class))).thenReturn(false);
when(iwm.inWorld(any(Location.class))).thenReturn(false);
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
listener.onVisitorGetDamage(e);
assertFalse(e.isCancelled());
}
use of org.bukkit.event.entity.EntityDamageEvent in project BentoBox by BentoBoxWorld.
the class InvincibleVisitorsListenerTest method testOnVisitorGetDamageNotVoid.
@Test
public void testOnVisitorGetDamageNotVoid() {
EntityDamageEvent e = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.CRAMMING, 0D);
listener.onVisitorGetDamage(e);
assertTrue(e.isCancelled());
verify(player, never()).setGameMode(eq(GameMode.SPECTATOR));
}
use of org.bukkit.event.entity.EntityDamageEvent in project MiniGameWorld by MiniGameWorlds.
the class MiniGame method processEventWhileWaiting.
/**
* Processes events while players are waiting for start
*
* @param event Passed Event
*/
private void processEventWhileWaiting(Event event) {
if (event instanceof EntityDamageEvent) {
// prevent player hurts
EntityDamageEvent e = (EntityDamageEvent) event;
e.setCancelled(true);
} else if (event instanceof FoodLevelChangeEvent) {
// prevent player hunger changes
FoodLevelChangeEvent e = (FoodLevelChangeEvent) event;
e.setCancelled(true);
}
}
use of org.bukkit.event.entity.EntityDamageEvent in project WindSpigot by Wind-Development.
the class KillCommand method execute.
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender))
return true;
if (sender instanceof Player) {
Player player = (Player) sender;
EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000);
Bukkit.getPluginManager().callEvent(ede);
if (ede.isCancelled())
return true;
ede.getEntity().setLastDamageCause(ede);
player.setHealth(0);
sender.sendMessage("Ouch. That look like it hurt.");
} else {
sender.sendMessage("You can only perform this command as a player");
}
return true;
}
Aggregations