@EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamage(EntityDamageEvent ede) {
    List<EntityType> canDamageTypes = new ArrayList<EntityType>();
    canDamageTypes.add(EntityType.PLAYER);

    if (Main.getInstance().getServer().getPluginManager().isPluginEnabled("AntiAura")) {
      canDamageTypes.add(EntityType.SQUID);
    }

    if (canDamageTypes.contains(ede.getEntityType())) {
      return;
    }

    Game game =
        Main.getInstance().getGameManager().getGameByLocation(ede.getEntity().getLocation());
    if (game == null) {
      return;
    }

    if (game.getState() == GameState.STOPPED) {
      return;
    }

    ede.setCancelled(true);
  }
Пример #2
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void damageHandler(EntityDamageEvent event) {
   if (event.getEntityType() == EntityType.PLAYER) {
     AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId());
     if (p != null && p.getKit().equals(this) && p.getData("Cur") != null) {
       if (event.getCause() == DamageCause.FALL) event.setCancelled(true);
       else endLeap((Player) event.getEntity(), p);
     }
   }
 }
Пример #3
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamage(EntityDamageEvent event) {

    Entity entity = event.getEntity();
    EntityType type = event.getEntityType();

    if (isWorld(entity.getWorld())) {

      MetadataValue isFireplace;
      if (type == EntityType.ARMOR_STAND
          && (isFireplace = EntityChecker.getMeta(entity, "isFireplace")) != null
          && isFireplace.asBoolean()) {
        event.setCancelled(true); // prevent armor stand from burning away before it's done
      }
    }
  }
Пример #4
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void damageHandler(EntityDamageEvent event) {
   if (event.getEntityType() == EntityType.PLAYER) {
     AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId());
     if (p != null
         && p.getTeam() != null
         && !p.getTeam().isTeamDead()
         && p.getTeam().getNexus().getLocation() != null
         && p.getKit().equals(this)) {
       Player player = (Player) event.getEntity();
       if (player.getLocation().distanceSquared(p.getTeam().getNexus().getLocation().toLocation())
           <= 20 * 20)
         player.addPotionEffect(
             new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0));
       else player.removePotionEffect(PotionEffectType.REGENERATION);
     }
   }
 }