Beispiel #1
0
 /** Counts: - EnderDragons - EnderCrystals */
 private void countEntities() {
   if (this.endWorld.getEnvironment() == Environment.THE_END) {
     this.plugin.getLogger().info("Counting existing EDs in " + this.endWorld.getName() + "...");
     for (final EndChunk c : this.chunks.getSafeChunksList()) {
       if (this.endWorld.isChunkLoaded(c.getX(), c.getZ())) {
         final Chunk chunk = this.endWorld.getChunkAt(c.getX(), c.getZ());
         for (final Entity e : chunk.getEntities()) {
           if (e.getType() == EntityType.ENDER_DRAGON) {
             final EnderDragon ed = (EnderDragon) e;
             if (!this.dragons.containsKey(ed.getUniqueId())) {
               ed.setMaxHealth(this.config.getEdHealth());
               ed.setHealth(ed.getMaxHealth());
               this.dragons.put(ed.getUniqueId(), new HashMap<String, Double>());
               this.loadedDragons.add(ed.getUniqueId());
             }
           } else if (e.getType() == EntityType.ENDER_CRYSTAL) {
             c.addCrystalLocation(e);
           }
         }
       } else {
         this.endWorld.loadChunk(c.getX(), c.getZ());
         c.resetSavedDragons();
         this.endWorld.unloadChunkRequest(c.getX(), c.getZ());
       }
     }
     this.plugin
         .getLogger()
         .info("Done, " + this.getNumberOfAliveEnderDragons() + " EnderDragon(s) found.");
   }
 }
Beispiel #2
0
  @EventHandler(priority = EventPriority.HIGH)
  public void onEntityDamage(EntityDamageEvent event_) {
    // If the event is cancelled, then we want to return.
    if (event_.isCancelled() == true) return;

    // Block damage in creative world.
    WorldConfig wm = new WorldConfig();

    if (!wm.getIsRpg(event_.getEntity().getWorld().getName())) return;

    // Store event.
    event = event_;

    // Set defaults.
    setGlobalDefaults();

    // Always set event damage to 0.
    event.setDamage(0);

    boolean dealEnviromentalDamage = false;

    // For entity damage events we want to handle the attck normally.
    if (event instanceof EntityDamageByEntityEvent) {
      Entity damager = ((EntityDamageByEntityEvent) event).getDamager();

      if (damager.getType() == EntityType.WITHER) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.WITHER_SKULL) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.SPLASH_POTION) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.PRIMED_TNT) dealEnviromentalDamage = true;
      else entityAttack((EntityDamageByEntityEvent) event, -1);
    } else dealEnviromentalDamage = true;

    // Else we want to deal the damage to the player/mob as though not from an entity.
    if (dealEnviromentalDamage == true) {
      // If the defender is a player, then we attacker player defender.
      if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();

        // Prevent damage done to already dead players
        if (FC_Rpg.rpgEntityManager.getRpgPlayer(player).playerConfig.getIsActive() == true) {
          if (FC_Rpg.rpgEntityManager.getRpgPlayer(player).getIsAlive() == false) return;
        }

        // Prepare the defender.
        prepareDefender(player);

        double damage = getEnviromentalDamage(player);

        if (damage == 0) return;

        // Attack the player with enviromental damage.
        edm.attackPlayerDefender(
            rpgDefender, null, null, damage, damageType, event.getCause().toString());
      } else {
        // If the event entity is a livingentity and the damage isn't fall damage, then nuke.
        if (event.getCause() != DamageCause.FALL && event.getEntity() instanceof LivingEntity)
          edm.nukeMob((LivingEntity) event.getEntity());
      }
    }
  }
  private AbstractRewardSource getRewardSource(Entity entity) {
    AbstractRewardSource source = null;

    if (hasRewardSource(entity.getType())) {
      source = getRewardSource(entity.getType());
    } else {
      LoggerUtil.getInstance().warning("No reward found for entity: " + entity.getType().getName());
    }

    return source;
  }
  @Override
  public void onInteractEntity(PlayerInteractEntityEvent event, PlayerDetails details) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    if (EntityNBT.isValidType(entity.getType())) {
      EntityNBT entityNBT = EntityNBT.fromEntity(entity);
      player.sendMessage(
          ChatColor.YELLOW + "Information about " + EntityTypeMap.getName(entity.getType()) + "");
      for (NBTVariableContainer vc : entityNBT.getAllVariables()) {
        player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + vc.getName() + ":");
        for (NBTVariable var : vc) {
          String value = var.getValue();
          player.sendMessage(
              "  "
                  + ChatColor.AQUA
                  + var.getName()
                  + ": "
                  + ChatColor.WHITE
                  + (value != null ? value : ChatColor.ITALIC + "none"));
        }
      }
      player.sendMessage(ChatColor.YELLOW + "Extra information:");

      boolean extra = false;
      if (entityNBT instanceof MobNBT) {
        float[] chances = ((MobNBT) entityNBT).getDropChances();
        String[] names = {"head", "chest", "legs", "feet", "hand"};
        player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "Drop chance:");
        for (int i = 0; i < 5; ++i) {
          player.sendMessage(
              "  " + ChatColor.AQUA + names[i] + ": " + ChatColor.WHITE + chances[4 - i]);
        }
        extra = true;
      }
      if (entityNBT instanceof VillagerNBT) {
        VillagerNBT villagerNBT = (VillagerNBT) entityNBT;
        player.sendMessage("" + ChatColor.LIGHT_PURPLE + ChatColor.ITALIC + "Trades done:");
        int i = 1;
        for (VillagerNBTOffer offer : villagerNBT.getOffers()) {
          player.sendMessage(
              "  " + ChatColor.AQUA + "trade " + i + ": " + ChatColor.WHITE + offer.getUses());
          ++i;
        }
        extra = true;
      }
      if (!extra) {
        player.sendMessage("none");
      }
      event.setCancelled(true);
    } else {
      player.sendMessage(ChatColor.RED + "Not a valid entity!");
    }
  }
 public void clearEnt() {
   for (Entity e : getCorn().getWorld().getEntities()) {
     if (e.getType() == EntityType.DROPPED_ITEM
         || e.getType() == EntityType.CREEPER
         || e.getType() == EntityType.SKELETON
         || e.getType() == EntityType.SPIDER
         || e.getType() == EntityType.ENDERMAN
         || e.getType() == EntityType.ZOMBIE) {
       e.remove();
     }
   }
 }
 public static void doBoundingBox(TargetedDisguise disguise) {
   // TODO Slimes
   Entity entity = disguise.getEntity();
   if (entity != null) {
     if (isDisguiseInUse(disguise)) {
       DisguiseValues disguiseValues = DisguiseValues.getDisguiseValues(disguise.getType());
       FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
       if (disguiseValues.getBabyBox() != null) {
         if ((disguise.getWatcher() instanceof AgeableWatcher
                 && ((AgeableWatcher) disguise.getWatcher()).isBaby())
             || (disguise.getWatcher() instanceof ZombieWatcher
                 && ((ZombieWatcher) disguise.getWatcher()).isBaby())) {
           disguiseBox = disguiseValues.getBabyBox();
         }
       }
       ReflectionManager.setBoundingBox(entity, disguiseBox);
     } else {
       DisguiseValues entityValues =
           DisguiseValues.getDisguiseValues(DisguiseType.getType(entity.getType()));
       FakeBoundingBox entityBox = entityValues.getAdultBox();
       if (entityValues.getBabyBox() != null) {
         if ((entity instanceof Ageable && !((Ageable) entity).isAdult())
             || (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
           entityBox = entityValues.getBabyBox();
         }
       }
       ReflectionManager.setBoundingBox(entity, entityBox);
     }
   }
 }
  public boolean getBlockBelowFromEntity(Entity e) {

    boolean reqsBlockBelow = true;

    switch (e.getType()) {
      case ENDER_DRAGON:
        reqsBlockBelow = false;
        break;
      case WITHER:
        reqsBlockBelow = false;
        break;
      case BLAZE:
        reqsBlockBelow = false;
        break;
      case BAT:
        reqsBlockBelow = false;
        break;
      default:
        reqsBlockBelow = true;
        if (e instanceof Flying) {
          reqsBlockBelow = false;
        }
        if (e instanceof WaterMob) {
          reqsBlockBelow = false;
        }
        if (!(e instanceof LivingEntity)) {
          reqsBlockBelow = false;
        }
        break;
    }

    return reqsBlockBelow;
  }
 @Override
 public boolean standsOnEntity(
     final Entity entity,
     final double minX,
     final double minY,
     final double minZ,
     final double maxX,
     final double maxY,
     final double maxZ) {
   try {
     // TODO: Probably check other ids too before doing this ?
     for (final Entity other : entity.getNearbyEntities(2.0, 2.0, 2.0)) {
       final EntityType type = other.getType();
       if (type != EntityType.BOAT) { //  && !(other instanceof Minecart))
         continue;
       }
       final double locY = entity.getLocation(useLoc).getY();
       useLoc.setWorld(null);
       if (Math.abs(locY - minY) < 0.7) {
         // TODO: A "better" estimate is possible, though some more tolerance would be good.
         return true;
       } else return false;
     }
   } catch (Throwable t) {
     // Ignore exceptions (Context: DisguiseCraft).
   }
   return false;
 }
Beispiel #9
0
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onEntityRightClick(PlayerInteractEntityEvent event) {
   QuestManager qm = Quester.qMan;
   Player player = event.getPlayer();
   Quest quest = qm.getPlayerQuest(player.getName());
   if (quest != null) {
     if (!quest.allowedWorld(player.getWorld().getName().toLowerCase())) return;
     List<Objective> objs = quest.getObjectives();
     Entity entity = event.getRightClicked();
     ItemStack item = player.getItemInHand();
     for (int i = 0; i < objs.size(); i++) {
       if (objs.get(i).getType().equalsIgnoreCase("DYE")) {
         if (!qm.isObjectiveActive(player, i)) {
           continue;
         }
         DyeObjective obj = (DyeObjective) objs.get(i);
         if (entity.getType() == EntityType.SHEEP) {
           Sheep sheep = (Sheep) entity;
           if (item.getType() == Material.INK_SACK
               && obj.checkDye(15 - item.getDurability())
               && sheep.getColor().getDyeData() != (15 - item.getDurability())) {
             qm.incProgress(player, i);
             return;
           }
         }
       }
     }
   }
 }
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void creatureSpawnEvent(EntitySpawnEvent event) {
   Entity entity = event.getEntity();
   Location location = BukkitUtil.getLocation(entity.getLocation());
   PlotArea area = location.getPlotArea();
   if (area == null) {
     return;
   }
   Plot plot = area.getOwnedPlotAbs(location);
   if (plot == null) {
     return;
   }
   if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
     event.setCancelled(true);
   }
   switch (entity.getType()) {
     case ENDER_CRYSTAL:
       if (plot == null) {
         if (!area.MOB_SPAWNING) {
           event.setCancelled(true);
         }
         return;
       }
       if (PlayerEvents.checkEntity(entity, plot)) {
         event.setCancelled(true);
       }
   }
 }
 @EventHandler
 public void onDammange(EntityDamageByEntityEvent event) {
   Entity dammage = event.getEntity();
   if (dammage.getType() == EntityType.ENDER_CRYSTAL) {
     event.setCancelled(true);
   }
 }
Beispiel #12
0
 /*
 Thanks to StackOverflow - "this-Me" !
  */
 public static boolean isValidEntity(Entity e) {
   EntityType et = e.getType();
   return !(et == EntityType.ITEM_FRAME
       || et == EntityType.BOAT
       || et == EntityType.ARROW
       || et == EntityType.ENDER_CRYSTAL
       || et == EntityType.COMPLEX_PART
       || et == EntityType.EGG
       || et == EntityType.DROPPED_ITEM
       || et == EntityType.ENDER_PEARL
       || et == EntityType.ENDER_SIGNAL
       || et == EntityType.EXPERIENCE_ORB
       || et == EntityType.FALLING_BLOCK
       || et == EntityType.FIREBALL
       || et == EntityType.LIGHTNING
       || et == EntityType.MINECART
       || et == EntityType.PAINTING
       || et == EntityType.PRIMED_TNT
       || et == EntityType.SMALL_FIREBALL
       || et == EntityType.SNOWBALL
       || et == EntityType.SPLASH_POTION
       || et == EntityType.THROWN_EXP_BOTTLE
       || et == EntityType.UNKNOWN
       || et == EntityType.WEATHER
       || et == EntityType.WITHER_SKULL);
 }
Beispiel #13
0
 /**
  * Intended for vehicle-move events.
  *
  * @param player
  * @param vehicle
  * @param from
  * @param to
  * @param fake true if the event was not fired by an external source (just gets noted).
  */
 public static void outputDebugVehicleMove(
     final Player player,
     final Entity vehicle,
     final Location from,
     final Location to,
     final boolean fake) {
   final StringBuilder builder = new StringBuilder(250);
   final Location vLoc = vehicle.getLocation();
   final Location loc = player.getLocation();
   // TODO: Differentiate debug levels (needs setting up some policy + document in
   // BuildParamteres)?
   final Entity actualVehicle = player.getVehicle();
   final boolean wrongVehicle =
       actualVehicle == null || actualVehicle.getEntityId() != vehicle.getEntityId();
   if (BuildParameters.debugLevel > 0) {
     builder.append(
         "\n-------------- VEHICLE MOVE " + (fake ? "(fake)" : "") + "--------------\n");
     builder.append(player.getName() + " " + from.getWorld().getName() + ":\n");
     addMove(from, to, null, builder);
     builder.append("\n Vehicle: ");
     addLocation(vLoc, builder);
     builder.append("\n Player: ");
     addLocation(loc, builder);
   } else {
     builder.append(
         player.getName()
             + " "
             + from.getWorld().getName()
             + "veh."
             + (fake ? "(fake)" : "")
             + " ");
     addFormattedMove(from, to, null, builder);
     builder.append("\n Vehicle: ");
     addFormattedLocation(vLoc, builder);
     builder.append(" Player: ");
     addFormattedLocation(loc, builder);
   }
   builder.append(
       "\n Vehicle type: "
           + vehicle.getType()
           + (wrongVehicle
               ? (actualVehicle == null ? " (exited?)" : " actual: " + actualVehicle.getType())
               : ""));
   NCPAPIProvider.getNoCheatPlusAPI()
       .getLogManager()
       .debug(Streams.TRACE_FILE, builder.toString());
 }
Beispiel #14
0
 public static String getName(org.bukkit.entity.Entity paramEntity) {
   if (paramEntity == null) {
     return "Null";
   }
   if (paramEntity.getType() == EntityType.PLAYER) {
     return ((Player) paramEntity).getName();
   }
   if (GetEntityNames().containsKey(paramEntity)) {
     return (String) GetEntityNames().get(paramEntity);
   }
   if ((paramEntity instanceof LivingEntity)) {
     LivingEntity localLivingEntity = (LivingEntity) paramEntity;
     if (localLivingEntity.getCustomName() != null) {
       return localLivingEntity.getCustomName();
     }
   }
   return getName(paramEntity.getType());
 }
 public boolean blockEntityPickup(Entity entity) {
   if (entity.getType() == EntityType.SKELETON
       || entity.getType() == EntityType.ZOMBIE
       || entity.getType() == EntityType.PIG_ZOMBIE) {
     Location el = entity.getLocation();
     World ew = el.getWorld();
     double ex = el.getX();
     double ez = el.getZ();
     if (w.equals(ew)) {
       if (Math.abs(ex - x) < 1000) {
         if (Math.abs(ez - z) < 1000) {
           return true;
         }
       }
     }
   }
   return false;
 }
Beispiel #16
0
  @EventHandler(priority = EventPriority.HIGH)
  public void removeItemFromFrame(EntityDamageByEntityEvent event) {
    Entity victim = event.getEntity();

    if (!victim.getType().equals(EntityType.ITEM_FRAME)) {
      return;
    }
    Player p;
    Entity attacker = event.getDamager();
    // System.out.println("Attacker: "+attacker.getType().toString());
    if (attacker.getType().toString().equals("PLAYER")) {
      p = (Player) attacker;

      OwnedLand land = OwnedLand.getApplicableLand(victim.getLocation());
      if (land == null) {
        return;
      }
      if (!land.hasPermTo(p, this)) {
        p.sendMessage(
            ChatColor.RED
                + getPlugin().getMessageConfig().getString("event.build.itemFrameRemoveWithMelee"));
        event.setCancelled(true);
      }

    } else if (attacker.getType().toString().equals("ARROW")) {
      Arrow a = (Arrow) attacker;
      if (a.getShooter() instanceof Player) {
        p = (Player) a.getShooter();
      } else {
        return;
      }

      OwnedLand land = OwnedLand.getApplicableLand(victim.getLocation());
      if (land == null) {
        return;
      }
      if (!land.hasPermTo(p, this)) {
        p.sendMessage(
            ChatColor.RED
                + getPlugin().getMessageConfig().getString("event.build.itemFrameRemoveWithArrow"));
        event.setCancelled(true);
      }
    }
  }
  public static boolean isShopItem(Entity s) {
    if (s.getType() == EntityType.DROPPED_ITEM) {
      for (ShopItem i : items) {
        if (i.item.getEntityId() == s.getEntityId()) {
          return true;
        }
      }
    }

    return false;
  }
Beispiel #18
0
 private void disguise(Entity entity, Player p) {
   if ((entity instanceof Animals && disguiseAsAnimal)
       || (entity instanceof Monster && disguiseAsMonster)) {
     if (hasAbility(p)) {
       if (!DisguiseAPI.isDisguised(p))
         DisguiseAPI.disguiseToAll(
             p, new MobDisguise(DisguiseType.valueOf(entity.getType().name()), true));
       else {
         Disguise disguise = DisguiseAPI.getDisguise(p);
         if (disguise.getType() == DisguiseType.valueOf(entity.getType().name())) return;
         DisguiseAPI.disguiseToAll(
             p, new MobDisguise(DisguiseType.valueOf(entity.getType().name()), true));
       }
       p.sendMessage(
           String.format(
               chameleonNowDisguised,
               HungergamesApi.getKitManager().toReadable(entity.getType().getName())));
     }
   }
 }
  public static ShopItem getShopItem(Entity s) {
    if (s.getType() == EntityType.DROPPED_ITEM) {
      for (ShopItem i : items) {
        if (i.item.getEntityId() == s.getEntityId()) {
          return i;
        }
      }
    }

    return null;
  }
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onClick(PlayerInteractEntityEvent event) {
   Player player = event.getPlayer();
   Entity entity = event.getRightClicked();
   if (entity == null) {
     return;
   }
   if (entity.getType() != EntityType.ITEM_FRAME && entity.getType() != EntityType.ARMOR_STAND) {
     return;
   }
   if (entity.getType() == EntityType.ITEM_FRAME) {
     if (!AllowAction.allowAction(entity.getLocation(), player, FlagManager.ITEMFRAME)) {
       event.setCancelled(true);
     }
   } else {
     if (!AllowAction.allowAction(entity.getLocation(), player, FlagManager.ARMORSTAND)) {
       event.setCancelled(true);
     }
   }
 }
Beispiel #21
0
 @Override
 public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
   Entity ent = getExpr().getSingle(e); // Called to get the Target which is Player in this case.
   if (ent == null) return;
   if (ent.getType() != EntityType.ARMOR_STAND) {
     return;
   }
   Boolean b = (Boolean) (delta[0]);
   if (mode == Changer.ChangeMode.SET) {
     ((ArmorStand) ent).setSmall(b);
   }
 }
Beispiel #22
0
  public boolean checkProjectile(Entity entity, DamageCause dmg) {

    if (dmg == DamageCause.PROJECTILE) {

      if (entity.getType() == EntityType.ARROW) {

        return true;
      }
    }

    return false;
  }
 public Shield getShield(Entity entity) {
   // Get shield by crystal entity.
   if (entity.getType() == EntityType.ENDER_CRYSTAL) {
     for (Shield shield : this.shields) {
       // FIXME somehow the crystal is located at y+1
       if (shield.getLocation().equals(entity.getLocation().clone().subtract(0, 1, 0))) {
         return shield;
       }
     }
   }
   return null;
 }
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent evt) {
   if (!FriendMe.friendlyFire) return;
   Entity cause = evt.getDamager();
   Entity player = evt.getEntity();
   if (player.getType().equals(EntityType.PLAYER) && cause.getType().equals(EntityType.PLAYER)) {
     Player playerCause = (Player) cause;
     Player damageCause = (Player) player;
     for (Friendship f : FriendMe.friendships) {
       if (f.getSender().equals(playerCause) && f.getReceiver().equals(damageCause)) {
         evt.setCancelled(true);
         FriendMe.sendMessage(damageCause, Type.FRIENDLY_FIRE, null);
       } else if (f.getReceiver().equals(playerCause) && f.getSender().equals(damageCause)) {
         evt.setCancelled(true);
         FriendMe.sendMessage(damageCause, Type.FRIENDLY_FIRE, null);
       }
     }
   } else {
     return;
   }
 }
  private boolean killDecision(
      Entity e,
      List<String> thingsToKill,
      boolean negateAnimals,
      boolean negateMonsters,
      boolean specifiedAnimals,
      boolean specifiedMonsters) {
    boolean negate = false;
    boolean specified = false;
    if (e instanceof Golem || e instanceof Squid || e instanceof Animals) {
      // it's an animal
      if (specifiedAnimals && !negateAnimals) {
        Logging.finest(
            "Removing an entity because I was told to remove all animals in world %s: %s",
            e.getWorld().getName(), e);
        return true;
      }
      if (specifiedAnimals) specified = true;
      negate = negateAnimals;
    } else if (e instanceof Monster || e instanceof Ghast || e instanceof Slime) {
      // it's a monster
      if (specifiedMonsters && !negateMonsters) {
        Logging.finest(
            "Removing an entity because I was told to remove all monsters in world %s: %s",
            e.getWorld().getName(), e);
        return true;
      }
      if (specifiedMonsters) specified = true;
      negate = negateMonsters;
    }
    for (String s : thingsToKill) {
      EntityType type = EntityType.fromName(s);
      if (type != null && type.equals(e.getType())) {
        specified = true;
        if (!negate) {
          Logging.finest(
              "Removing an entity because it WAS specified and we are NOT negating in world %s: %s",
              e.getWorld().getName(), e);
          return true;
        }
        break;
      }
    }
    if (!specified && negate) {
      Logging.finest(
          "Removing an entity because it was NOT specified and we ARE negating in world %s: %s",
          e.getWorld().getName(), e);
      return true;
    }

    return false;
  }
 @EventHandler(priority = EventPriority.NORMAL)
 public void onEntityInteract(EntityInteractEvent event) {
   Block block = event.getBlock();
   Material mat = block.getType();
   Entity entity = event.getEntity();
   FlagPermissions perms = Residence.getPermsByLoc(block.getLocation());
   boolean hastrample = perms.has("trample", perms.has("hasbuild", true));
   if (!hastrample
       && !(entity.getType() == EntityType.FALLING_BLOCK)
       && (mat == Material.SOIL || mat == Material.SOUL_SAND)) {
     event.setCancelled(true);
   }
 }
 @EventHandler(priority = EventPriority.LOWEST)
 public void onEntityInteract(EntityInteractEvent event) {
   Block block = event.getBlock();
   Material mat = block.getType();
   Entity entity = event.getEntity();
   if ((entity.getType() == EntityType.FALLING_BLOCK)
       || !(mat == Material.SOIL || mat == Material.SOUL_SAND)) {
     return;
   }
   if (!AllowAction.allowAction(block.getLocation(), FlagManager.TRAMPLE)) {
     event.setCancelled(true);
   }
 }
Beispiel #28
0
  /**
   * Apply combat modifiers
   *
   * @param event The event to run the combat checks on.
   */
  void combatChecks(EntityDamageByEntityEvent event) {
    Entity damager = event.getDamager();
    EntityType damagerType = damager.getType();

    switch (damagerType) {
      case PLAYER:
        Player attacker = (Player) event.getDamager();
        ItemStack itemInHand = attacker.getItemInHand();

        DurabilityUtils.handleInfiniteDurability(itemInHand);
      default:
        return;
    }
  }
  /**
   * Remove creatures from chunk at and around the given location.
   *
   * @param l
   */
  public void removeCreatures(Location l) {
    if (!this.settings.getRemoveCreaturesByTeleport() || l == null) {
      return;
    }

    int px = l.getBlockX();
    int py = l.getBlockY();
    int pz = l.getBlockZ();
    for (int x = -1; x <= 1; x++) {
      for (int z = -1; z <= 1; z++) {
        Chunk c = l.getWorld().getChunkAt(new Location(l.getWorld(), px + x * 16, py, pz + z * 16));
        for (Entity e : c.getEntities()) {
          if (e.getType() == EntityType.SPIDER
              || e.getType() == EntityType.CREEPER
              || e.getType() == EntityType.ENDERMAN
              || e.getType() == EntityType.SKELETON
              || e.getType() == EntityType.ZOMBIE) {
            e.remove();
          }
        }
      }
    }
  }
  public static String getEntityName(Entity entity) {

    String entityName = null;
    if (!EpicSystem.useCitizens()) {
      if (entity instanceof Villager) entityName = ((Villager) entity).getCustomName();
    } else {
      if (CitizensAPI.getNPCRegistry().isNPC(entity)) {
        NPC citizensNPC = CitizensAPI.getNPCRegistry().getNPC(entity);
        entityName = ChatColor.stripColor(citizensNPC.getName());
      }
    }
    if (entityName == null) entityName = entity.getType().toString();
    return entityName;
  }