public void onEntityDamage(EntityDamageEvent event) { if (event instanceof EntityDamageByEntityEvent || event instanceof EntityDamageByProjectileEvent) { handlerAttackDefend((EntityDamageByEntityEvent) event); } else if (event.getCause() == DamageCause.FIRE_TICK) { Entity entity = event.getEntity(); if (entity instanceof Player) { Player player = (Player) entity; Team team = war.getPlayerTeam(player.getName()); if (team != null && team.getSpawnVolume().contains(player.getLocation())) { // smother out the fire that didn't burn out when you respawned // Stop fire (upcast, watch out!) if (player instanceof CraftPlayer) { net.minecraft.server.Entity playerEntity = ((CraftPlayer) player).getHandle(); playerEntity.fireTicks = 0; } event.setCancelled(true); } } } else if (event.getCause() == DamageCause.DROWNING) { Entity entity = event.getEntity(); if (entity instanceof Player) { Player player = (Player) entity; Team team = war.getPlayerTeam(player.getName()); if (team != null && player.getHealth() <= 0) { // don't keep killing drowing player: trying to stop "Player moved wrongly!" error at // respawn. event.setCancelled(true); } } } }
public void onEntityCombust(EntityCombustEvent event) { Entity entity = event.getEntity(); if (entity instanceof Player) { Player player = (Player) entity; Team team = war.getPlayerTeam(player.getName()); if (team != null && team.getSpawnVolume().contains(player.getLocation())) { // smother out the fire that didn't burn out when you respawned // Stop fire (upcast, watch out!) if (player instanceof CraftPlayer) { net.minecraft.server.Entity playerEntity = ((CraftPlayer) player).getHandle(); playerEntity.fireTicks = 0; } event.setCancelled(true); } } }
public void setFireTicks(int ticks) { entity.fireTicks = ticks; }