if (item.isWeapon())
WorldStatisticsManager.getInstance().updateStat(player, CategoryType.WEAPON_ENCHANT_MAX, item.getCrystalType().ordinal(), item.getEnchantLevel());
player.sendPacket(new EnchantResult(0, 0, 0L, item.getEnchantLevel()));
if (Config.SHOW_ENCHANT_EFFECT_RESULT)
{
player.broadcastPacket(new L2GameServerPacket[] { new SystemMessage(3013).addName(player).addNumber(item.getEnchantLevel()).addItemName(item.getItemId()) });
player.broadcastPacket(new L2GameServerPacket[] { new MagicSkillUse(player, player, 5965, 1, 500, 1500L) });
}
}
else
{
switch (esi.getType())
{
case NORMAL:
if (item.isEquipped())
{
player.sendDisarmMessage(item);
}
if (!inventory.destroyItem(item, 1L))
{
player.sendActionFailed();
return;
}
int crystalId = item.getCrystalType().cry;
if ((crystalId > 0) && (item.getTemplate().getCrystalCount() > 0))
{
int crystalAmount = (int) (item.getTemplate().getCrystalCount() * 0.87D);
if (item.getEnchantLevel() > 3)
{
crystalAmount = (int) (crystalAmount + (item.getTemplate().getCrystalCount() * 0.25D * (item.getEnchantLevel() - 3)));
}
if (crystalAmount < 1)
{
crystalAmount = 1;
}
player.sendPacket(new EnchantResult(1, crystalId, crystalAmount));
ItemFunctions.addItem(player, crystalId, crystalAmount, true);
}
else
{
player.sendPacket(EnchantResult.FAILED_NO_CRYSTALS);