Program: 187554
Project: 187554
Buggy source:
@EventHandler public void onMyPetEntityDeath(final EntityDeathEvent event){
  if (event.getEntity() instanceof CraftMyPet) {
    MyPet myPet=((CraftMyPet)event.getEntity()).getMyPet();
    if (myPet == null) {
      return;
    }
    myPet.status=PetState.Dead;
    myPet.respawnTime=(MyPetConfiguration.RESPAWN_TIME_FIXED + MyPet.getCustomRespawnTimeFixed(myPet.getClass())) + (myPet.getExperience().getLevel() * (MyPetConfiguration.RESPAWN_TIME_FACTOR + MyPet.getCustomRespawnTimeFactor(myPet.getClass())));
    if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
      EntityDamageByEntityEvent e=(EntityDamageByEntityEvent)event.getEntity().getLastDamageCause();
      if (e.getDamager() instanceof Player) {
        myPet.respawnTime=(MyPetConfiguration.RESPAWN_TIME_PLAYER_FIXED + MyPet.getCustomRespawnTimeFixed(myPet.getClass())) + (myPet.getExperience().getLevel() * (MyPetConfiguration.RESPAWN_TIME_PLAYER_FACTOR + MyPet.getCustomRespawnTimeFactor(myPet.getClass())));
      }
 else       if (e.getDamager() instanceof CraftMyPet) {
        MyPet killerMyPet=((CraftMyPet)e.getDamager()).getMyPet();
        if (myPet.getSkills().isSkillActive("String_Node_Str") && killerMyPet.getSkills().isSkillActive("String_Node_Str")) {
          Behavior killerBehaviorSkill=(Behavior)killerMyPet.getSkills().getSkill("String_Node_Str");
          Behavior deadBehaviorSkill=(Behavior)myPet.getSkills().getSkill("String_Node_Str");
          if (deadBehaviorSkill.getBehavior() == BehaviorState.Duel && killerBehaviorSkill.getBehavior() == BehaviorState.Duel) {
            EntityMyPet myPetEntity=((CraftMyPet)event.getEntity()).getHandle();
            EntityMyPet duelKiller=((CraftMyPet)e.getDamager()).getHandle();
            if (myPetEntity.petTargetSelector.hasGoal("String_Node_Str")) {
              EntityAIDuelTarget duelTarget=(EntityAIDuelTarget)myPetEntity.petTargetSelector.getGoal("String_Node_Str");
              if (duelTarget.getDuelOpponent() == duelKiller) {
                myPet.respawnTime=10;
              }
            }
          }
        }
      }
    }
    event.setDroppedExp(0);
    if (MyPetConfiguration.USE_LEVEL_SYSTEM && MyPetExperience.LOSS_FIXED > 0 || MyPetExperience.LOSS_PERCENT > 0) {
      double lostExpirience=MyPetExperience.LOSS_FIXED;
      lostExpirience+=myPet.getExperience().getRequiredExp() * MyPetExperience.LOSS_PERCENT / 100;
      if (lostExpirience > myPet.getExperience().getCurrentExp()) {
        lostExpirience=myPet.getExperience().getCurrentExp();
      }
      if (MyPetExperience.DROP_LOST_EXP) {
        event.setDroppedExp((int)(lostExpirience + 0.5));
      }
      myPet.getExperience().removeCurrentExp(lostExpirience);
    }
    if (myPet.getSkills().isSkillActive("String_Node_Str")) {
      Inventory inventorySkill=(Inventory)myPet.getSkills().getSkill("String_Node_Str");
      inventorySkill.closeInventory();
      if (inventorySkill.dropOnDeath() && !myPet.getOwner().isMyPetAdmin()) {
        World world=((CraftWorld)event.getEntity().getLocation().getWorld()).getHandle();
        Location petLocation=event.getEntity().getLocation();
        MyPetCustomInventory inv=((Inventory)myPet.getSkills().getSkill("String_Node_Str")).inv;
        for (int i=0; i < inv.getSize(); i++) {
          net.minecraft.server.v1_5_R2.ItemStack is=inv.splitWithoutUpdate(i);
          if (is != null) {
            is=is.cloneItemStack();
            EntityItem itemEntity=new EntityItem(world,petLocation.getX(),petLocation.getY(),petLocation.getZ(),is);
            itemEntity.pickupDelay=10;
            world.addEntity(itemEntity);
          }
        }
      }
    }
    SendDeathMessage(event);
    myPet.sendMessageToOwner(MyPetBukkitUtil.setColors(MyPetLanguage.getString("String_Node_Str").replace("String_Node_Str",myPet.petName).replace("String_Node_Str","String_Node_Str" + myPet.respawnTime)));
    if (MyPetEconomy.canUseEconomy() && myPet.getOwner().hasAutoRespawnEnabled() && myPet.respawnTime >= myPet.getOwner().getAutoRespawnMin() && MyPetPermissions.has(myPet.getOwner().getPlayer(),"String_Node_Str")) {
      double costs=myPet.respawnTime * MyPetConfiguration.RESPAWN_COSTS_FACTOR + MyPetConfiguration.RESPAWN_COSTS_FIXED;
      if (MyPetEconomy.canPay(myPet.getOwner(),costs)) {
        MyPetEconomy.pay(myPet.getOwner(),costs);
        myPet.sendMessageToOwner(MyPetBukkitUtil.setColors(MyPetLanguage.getString("String_Node_Str").replace("String_Node_Str",costs + "String_Node_Str" + MyPetEconomy.getEconomy().currencyNameSingular()).replace("String_Node_Str",myPet.petName)));
        myPet.respawnTime=1;
      }
 else {
        myPet.sendMessageToOwner(MyPetBukkitUtil.setColors(MyPetLanguage.getString("String_Node_Str").replace("String_Node_Str",costs + "String_Node_Str" + MyPetEconomy.getEconomy().currencyNameSingular()).replace("String_Node_Str",myPet.petName)));
      }
    }
  }
}

Fixed version (ground truth):
@EventHandler public void onMyPetEntityDeath(final EntityDeathEvent event){
  if (event.getEntity() instanceof CraftMyPet) {
    MyPet myPet=((CraftMyPet)event.getEntity()).getMyPet();
    if (myPet == null || myPet.getHealth() > 0) {
      return;
    }
    myPet.status=PetState.Dead;
    myPet.respawnTime=(MyPetConfiguration.RESPAWN_TIME_FIXED + MyPet.getCustomRespawnTimeFixed(myPet.getClass())) + (myPet.getExperience().getLevel() * (MyPetConfiguration.RESPAWN_TIME_FACTOR + MyPet.getCustomRespawnTimeFactor(myPet.getClass())));
    if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) {
      EntityDamageByEntityEvent e=(EntityDamageByEntityEvent)event.getEntity().getLastDamageCause();
      if (e.getDamager() instanceof Player) {
        myPet.respawnTime=(MyPetConfiguration.RESPAWN_TIME_PLAYER_FIXED + MyPet.getCustomRespawnTimeFixed(myPet.getClass())) + (myPet.getExperience().getLevel() * (MyPetConfiguration.RESPAWN_TIME_PLAYER_FACTOR + MyPet.getCustomRespawnTimeFactor(myPet.getClass())));
      }
 else       if (e.getDamager() instanceof CraftMyPet) {
        MyPet killerMyPet=((CraftMyPet)e.getDamager()).getMyPet();
        if (myPet.getSkills().isSkillActive("String_Node_Str") && killerMyPet.getSkills().isSkillActive("String_Node_Str")) {
          Behavior killerBehaviorSkill=(Behavior)killerMyPet.getSkills().getSkill("String_Node_Str");
          Behavior deadBehaviorSkill=(Behavior)myPet.getSkills().getSkill("String_Node_Str");
          if (deadBehaviorSkill.getBehavior() == BehaviorState.Duel && killerBehaviorSkill.getBehavior() == BehaviorState.Duel) {
            EntityMyPet myPetEntity=((CraftMyPet)event.getEntity()).getHandle();
            EntityMyPet duelKiller=((CraftMyPet)e.getDamager()).getHandle();
            if (myPetEntity.petTargetSelector.hasGoal("String_Node_Str")) {
              EntityAIDuelTarget duelTarget=(EntityAIDuelTarget)myPetEntity.petTargetSelector.getGoal("String_Node_Str");
              if (duelTarget.getDuelOpponent() == duelKiller) {
                myPet.respawnTime=10;
              }
            }
          }
        }
      }
    }
    event.setDroppedExp(0);
    if (MyPetConfiguration.USE_LEVEL_SYSTEM && MyPetExperience.LOSS_FIXED > 0 || MyPetExperience.LOSS_PERCENT > 0) {
      double lostExpirience=MyPetExperience.LOSS_FIXED;
      lostExpirience+=myPet.getExperience().getRequiredExp() * MyPetExperience.LOSS_PERCENT / 100;
      if (lostExpirience > myPet.getExperience().getCurrentExp()) {
        lostExpirience=myPet.getExperience().getCurrentExp();
      }
      if (MyPetExperience.DROP_LOST_EXP) {
        event.setDroppedExp((int)(lostExpirience + 0.5));
      }
      myPet.getExperience().removeCurrentExp(lostExpirience);
    }
    if (myPet.getSkills().isSkillActive("String_Node_Str")) {
      Inventory inventorySkill=(Inventory)myPet.getSkills().getSkill("String_Node_Str");
      inventorySkill.closeInventory();
      if (inventorySkill.dropOnDeath() && !myPet.getOwner().isMyPetAdmin()) {
        World world=((CraftWorld)event.getEntity().getLocation().getWorld()).getHandle();
        Location petLocation=event.getEntity().getLocation();
        MyPetCustomInventory inv=((Inventory)myPet.getSkills().getSkill("String_Node_Str")).inv;
        for (int i=0; i < inv.getSize(); i++) {
          net.minecraft.server.v1_5_R2.ItemStack is=inv.splitWithoutUpdate(i);
          if (is != null) {
            is=is.cloneItemStack();
            EntityItem itemEntity=new EntityItem(world,petLocation.getX(),petLocation.getY(),petLocation.getZ(),is);
            itemEntity.pickupDelay=10;
            world.addEntity(itemEntity);
          }
        }
      }
    }
    SendDeathMessage(event);
    myPet.sendMessageToOwner(MyPetBukkitUtil.setColors(MyPetLanguage.getString("String_Node_Str").replace("String_Node_Str",myPet.petName).replace("String_Node_Str","String_Node_Str" + myPet.respawnTime)));
    if (MyPetEconomy.canUseEconomy() && myPet.getOwner().hasAutoRespawnEnabled() && myPet.respawnTime >= myPet.getOwner().getAutoRespawnMin() && MyPetPermissions.has(myPet.getOwner().getPlayer(),"String_Node_Str")) {
      double costs=myPet.respawnTime * MyPetConfiguration.RESPAWN_COSTS_FACTOR + MyPetConfiguration.RESPAWN_COSTS_FIXED;
      if (MyPetEconomy.canPay(myPet.getOwner(),costs)) {
        MyPetEconomy.pay(myPet.getOwner(),costs);
        myPet.sendMessageToOwner(MyPetBukkitUtil.setColors(MyPetLanguage.getString("String_Node_Str").replace("String_Node_Str",costs + "String_Node_Str" + MyPetEconomy.getEconomy().currencyNameSingular()).replace("String_Node_Str",myPet.petName)));
        myPet.respawnTime=1;
      }
 else {
        myPet.sendMessageToOwner(MyPetBukkitUtil.setColors(MyPetLanguage.getString("String_Node_Str").replace("String_Node_Str",costs + "String_Node_Str" + MyPetEconomy.getEconomy().currencyNameSingular()).replace("String_Node_Str",myPet.petName)));
      }
    }
  }
}