content: /**
   * This file is part of Aion-Lightning <aion-lightning.org>.
   *
   *  Aion-Lightning is free software: you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation, either version 3 of the License, or
   *  (at your option) any later version.
   *
   *  Aion-Lightning is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details. *
   *  You should have received a copy of the GNU General Public License
   *  along with Aion-Lightning.
   *  If not, see <http://www.gnu.org/licenses/>.
   */
  package com.aionemu.gameserver.network.aion.clientpackets;
  
  import com.aionemu.commons.network.util.ThreadPoolManager;
  import com.aionemu.gameserver.model.DescriptionId;
  import com.aionemu.gameserver.model.gameobjects.Item;
  import com.aionemu.gameserver.model.gameobjects.player.Player;
  import com.aionemu.gameserver.network.aion.AionClientPacket;
  import com.aionemu.gameserver.network.aion.AionConnection.State;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_ITEM_USAGE_ANIMATION;
  import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
  import com.aionemu.gameserver.services.enchant.EnchantService;
  import com.aionemu.gameserver.utils.PacketSendUtility;
  
  /**
   * @author Falke_34
   * @rework FrozenKiller
   */
  public class CM_ENCHANTMENT_EXTRACTION extends AionClientPacket {
  
  	private int itemObjectId;
  
  	public CM_ENCHANTMENT_EXTRACTION(int opcode, State state, State... restStates) {
  		super(opcode, state, restStates);
  	}
  
  	@Override
  	protected void readImpl() {
  		itemObjectId = readD();
  	}
  
  	@Override
  	protected void runImpl() {
  
  		final Player player = getConnection().getActivePlayer();
  		final Item targetItem = player.getInventory().getItemByObjId(itemObjectId);
  		ThreadPoolManager.getInstance().schedule(new Runnable() {
  
  			@Override
  			public void run() {
  				PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1300449, new DescriptionId(targetItem.getNameId())));
  				EnchantService.breakItem2(player, targetItem);
  				PacketSendUtility.broadcastPacket(player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), 0, targetItem.getObjectId(), targetItem.getItemTemplate().getTemplateId(), 0, 20), true);
  			}
  		}, 5000);
  		player.getInventory().tryDecreaseKinah(20000);
  		PacketSendUtility.broadcastPacket(player, new SM_ITEM_USAGE_ANIMATION(player.getObjectId(), 0, targetItem.getObjectId(), targetItem.getItemTemplate().getTemplateId(), 5000, 19), true);
  	}
  }
  