Пример #1
0
  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);
        }
      }
    }
  }
Пример #2
0
 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);
     }
   }
 }
Пример #3
0
 public void setFireTicks(int ticks) {
   entity.fireTicks = ticks;
 }