* @see lineage2.gameserver.listener.inventory.OnEquipListener#onEquip(int, ItemInstance, Playable)
*/
@Override
public void onEquip(int slot, ItemInstance item, Playable actor)
{
Player player = (Player) actor;
Skill[] itemSkills = null;
Skill enchant4Skill = null;
ItemTemplate it = item.getTemplate();
itemSkills = it.getAttachedSkills();
if (item.getEnchantLevel() >= 4)
{
enchant4Skill = it.getEnchant4Skill();
}
if ((it.getType2() == ItemTemplate.TYPE2_WEAPON) && (player.getWeaponsExpertisePenalty() > 0))
{
return;
}
player.addTriggers(it);
boolean needSendInfo = false;
if (itemSkills.length > 0)
{
for (Skill itemSkill : itemSkills)
{
if ((itemSkill.getId() >= 26046) && (itemSkill.getId() <= 26048))
{
int level = player.getSkillLevel(itemSkill.getId());
int newlevel = level;
if (level > 0)
{
if (SkillTable.getInstance().getInfo(itemSkill.getId(), level + 1) != null)
{
newlevel = level + 1;
}
}
else
{
newlevel = 1;
}
if (newlevel != level)
{
player.addSkill(SkillTable.getInstance().getInfo(itemSkill.getId(), newlevel), false);
}
}
else if (player.getSkillLevel(itemSkill.getId()) < itemSkill.getLevel())
{
player.addSkill(itemSkill, false);
if (itemSkill.isActive())
{
long reuseDelay = Formulas.calcSkillReuseDelay(player, itemSkill);
reuseDelay = Math.min(reuseDelay, 30000);
if ((reuseDelay > 0) && !player.isSkillDisabled(itemSkill))
{
player.disableSkill(itemSkill, reuseDelay);
needSendInfo = true;
}
}
}
}
}
if (enchant4Skill != null)
{
player.addSkill(enchant4Skill, false);
}
if ((itemSkills.length > 0) || (enchant4Skill != null))
{
player.sendSkillList();
player.updateStats();
if (needSendInfo)
{
player.sendPacket(new SkillCoolTime(player));
}
}
}