Looked in the code, when adding a sub class, it assigns the desired index. You re-assign the index -1 to the skills.
try
// solo le enseniamos el skill si es que el mismo no lo tiene aun o si es el inferior al q le vamos a enseniar
if (player.getSkillLevel(id) < level)
{
// Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
player.addSkill(skill, false);
}