Program: 179489
Project: 179489
Buggy source:
public void onEntityDamage(EntityDamageEvent event){
  if (event.isCancelled())   return;
  if (event instanceof EntityDamageByEntityEvent) {
    Entity entity=event.getEntity();
    Entity damager=((EntityDamageByEntityEvent)event).getDamager();
    if (damager instanceof Projectile) {
      damager=((Projectile)damager).getShooter();
    }
    if (entity instanceof Player) {
      Ride ride=plugin.getRideHandler().getRide(entity);
      if (ride.hasRider()) {
        if (!damager.equals(ride.getBukkitEntity()) && !damager.equals(ride.getTarget())) {
          ride.attack((LivingEntity)damager);
          return;
        }
      }
    }
    if (damager instanceof Player) {
      Ride ride=plugin.getRideHandler().getRide(damager);
      if (ride.hasRider()) {
        if (!entity.equals(ride.getBukkitEntity()) && !entity.equals(ride.getTarget())) {
          ride.attack((LivingEntity)entity);
          return;
        }
      }
    }
    if (damager instanceof LivingEntity) {
      Ride ride=plugin.getRideHandler().getRide(entity.getPassenger());
      if (ride.hasRider()) {
        if (!damager.equals(ride.getRider().getBukkitEntity())) {
          ride.attack((LivingEntity)damager);
        }
      }
    }
  }
 else   if (event instanceof EntityDamageByBlockEvent) {
    Entity rider=event.getEntity();
    Ride ride=plugin.getRideHandler().getRide(rider);
    if (rider instanceof Player && ride.getBukkitEntity() instanceof LivingEntity) {
switch (event.getCause()) {
case SUFFOCATION:
        event.setCancelled(true);
      break;
case DROWNING:
    if (ride.isWaterCreature())     event.setCancelled(true);
}
}
}
}

Fixed version (ground truth):
public void onEntityDamage(EntityDamageEvent event){
  if (event.isCancelled())   return;
  if (event instanceof EntityDamageByEntityEvent) {
    Entity entity=event.getEntity();
    Entity damager=((EntityDamageByEntityEvent)event).getDamager();
    if (damager instanceof Projectile) {
      damager=((Projectile)damager).getShooter();
    }
    if (entity instanceof Player) {
      Ride ride=plugin.getRideHandler().getRide(entity);
      if (ride.hasRider()) {
        if (damager.equals(ride.getBukkitEntity())) {
          event.setCancelled(true);
        }
 else         if (!damager.equals(ride.getBukkitEntity()) && !damager.equals(ride.getTarget())) {
          ride.attack((LivingEntity)damager);
          return;
        }
      }
    }
    if (damager instanceof Player) {
      Ride ride=plugin.getRideHandler().getRide(damager);
      if (ride.hasRider()) {
        if (!entity.equals(ride.getBukkitEntity()) && !entity.equals(ride.getTarget())) {
          ride.attack((LivingEntity)entity);
          return;
        }
      }
    }
    if (damager instanceof LivingEntity) {
      Ride ride=plugin.getRideHandler().getRide(entity.getPassenger());
      if (ride.hasRider()) {
        if (!damager.equals(ride.getRider().getBukkitEntity())) {
          ride.attack((LivingEntity)damager);
        }
      }
    }
  }
 else   if (event instanceof EntityDamageByBlockEvent) {
    Entity rider=event.getEntity();
    Ride ride=plugin.getRideHandler().getRide(rider);
    if (rider instanceof Player && ride.hasRider()) {
switch (event.getCause()) {
case SUFFOCATION:
        event.setCancelled(true);
      break;
case DROWNING:
    if (ride.isWaterCreature())     event.setCancelled(true);
}
}
}
}