Esempio n. 1
0
    private boolean entityInRange(BaseEntity entity) {
      switch (TYPE) {
        case 0:
          Player player = (Player) entity;

          return SETTINGS.isEmpty()
              || (SETTINGS.charAt(0) == 'g' && player.isInGroup(SETTINGS.substring(2)))
              || (SETTINGS.charAt(0) == 'p'
                  && player.getName().equalsIgnoreCase(SETTINGS.substring(2)));
        case 1:
        case 2:
          return true;
        case 3:
          if ((entity.isMob() || entity.isAnimal()) && entity instanceof Mob) {
            Mob mob = (Mob) entity;
            if (SETTINGS.isEmpty() || mob.getName().equalsIgnoreCase(SETTINGS)) return true;
          }
          break;
        case 4:
        case 5:
          return true;
      }

      return false;
    }
Esempio n. 2
0
  @SuppressWarnings("rawtypes")
  protected static boolean damageEntities(
      List list, World world, int x, int y, int z, int damage, String id) {
    y = getSafeY(world, x, y, z);

    boolean damaged = false;
    boolean isNamed =
        !id.isEmpty()
            && !id.equalsIgnoreCase("animal")
            && !id.equalsIgnoreCase("animals")
            && !id.equalsIgnoreCase("mob")
            && !id.equalsIgnoreCase("mobs");

    for (Object obj : list) {
      BaseEntity entity = (BaseEntity) obj;
      if (entity != null
          && entity
              .getWorld()
              .isChunkLoaded((int) entity.getX(), (int) entity.getY(), (int) entity.getZ())
          && (entity.isMob() || entity.isAnimal())) {
        Vector pVec = new Vector(entity.getX(), entity.getY(), entity.getZ());

        if (entity.getWorld() == world
            && (pVec.getBlockX() == x || pVec.getBlockX() == x + 1 || pVec.getBlockX() == x - 1)
            && pVec.getBlockY() == y
            && (pVec.getBlockZ() == z || pVec.getBlockZ() == z + 1 || pVec.getBlockZ() == z - 1)) {
          if (isNamed) {
            // Mob mob = (Mob)entity;
            if (entity.getName().equalsIgnoreCase(id)) {
              entity.getEntity().a(ODamageSource.j, damage);
              damaged = true;
            }
          } else {
            entity.getEntity().a(ODamageSource.j, damage);
            damaged = true;
          }
        }
      }
    }

    return damaged;
  }