{
activeChar.getInventory().unEquipItemInBodySlot(EhchantItem.getEquipSlot());
}
EhchantItem.setEnchantLevel(EchantVal);
activeChar.getInventory().equipItem(EhchantItem);
activeChar.sendPacket(new InventoryUpdate().addModifiedItem(EhchantItem));
activeChar.broadcastUserInfo();
activeChar.sendMessage("" + EhchantItem.getTemplate().getName() + " was enchanted to " + EchantVal + ". Thanks.");
onBypassCommand(activeChar, "_bbsechant;");
}
else
{
activeChar.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
}
}
if (command.startsWith("_bbsechant;enchantgoAtr;"))
{
StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
st.nextToken();
int EchantVal = Integer.parseInt(st.nextToken());
int AtrType = Integer.parseInt(st.nextToken());
Element el = Element.getElementById(AtrType);
int EchantPrice = Integer.parseInt(st.nextToken());
int EchantObjID = Integer.parseInt(st.nextToken());
ItemTemplate item = ItemHolder.getInstance().getTemplate(Config.ENCHANTER_ITEM_ID);
ItemInstance pay = activeChar.getInventory().getItemByItemId(item.getItemId());
ItemInstance EhchantItem = activeChar.getInventory().getItemByObjectId(EchantObjID);
if (EhchantItem.isWeapon())
{
if ((pay != null) && (pay.getCount() >= EchantPrice))
{
activeChar.getInventory().destroyItem(pay, EchantPrice);
if (EhchantItem.isEquipped())
{
activeChar.getInventory().unEquipItemInBodySlot(EhchantItem.getEquipSlot());
}
EhchantItem.setAttributeElement(el, EchantVal);
activeChar.getInventory().equipItem(EhchantItem);
activeChar.sendPacket(new InventoryUpdate().addModifiedItem(EhchantItem));
activeChar.broadcastUserInfo();
activeChar.sendMessage("" + EhchantItem.getTemplate().getName() + " was enchanted to " + EchantVal + ". Thanks.");
onBypassCommand(activeChar, "_bbsechant;");
}
else
{
activeChar.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
}
}
else if (EhchantItem.isArmor())
{
if (!canEnchantArmorAttribute(AtrType, EhchantItem))
{
activeChar.sendMessage("attribute reservation by region?");
onBypassCommand(activeChar, "_bbsechant;");
return;
}
if ((pay != null) && (pay.getCount() >= EchantPrice))
{
activeChar.getInventory().destroyItem(pay, EchantPrice);
if (EhchantItem.isEquipped())
{
activeChar.getInventory().unEquipItemInBodySlot(EhchantItem.getEquipSlot());
}
EhchantItem.setAttributeElement(el, EchantVal);
activeChar.getInventory().equipItem(EhchantItem);
activeChar.sendPacket(new InventoryUpdate().addModifiedItem(EhchantItem));
activeChar.broadcastUserInfo();
activeChar.sendMessage("" + EhchantItem.getTemplate().getName() + " was enchanted to " + EchantVal + ". Thanks.");
onBypassCommand(activeChar, "_bbsechant;");
}
}