UseItem.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.clientpackets;
  16. import java.util.Arrays;
  17. import java.util.logging.Logger;
  18. import net.sf.l2j.Config;
  19. import net.sf.l2j.gameserver.handler.IItemHandler;
  20. import net.sf.l2j.gameserver.handler.ItemHandler;
  21. import net.sf.l2j.gameserver.instancemanager.CastleManager;
  22. import net.sf.l2j.gameserver.model.Inventory;
  23. import net.sf.l2j.gameserver.model.L2Clan;
  24. import net.sf.l2j.gameserver.model.L2ItemInstance;
  25. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  26. import net.sf.l2j.gameserver.model.base.Race;
  27. import net.sf.l2j.gameserver.network.SystemMessageId;
  28. import net.sf.l2j.gameserver.serverpackets.ActionFailed;
  29. import net.sf.l2j.gameserver.serverpackets.InventoryUpdate;
  30. import net.sf.l2j.gameserver.serverpackets.ItemList;
  31. import net.sf.l2j.gameserver.serverpackets.ShowCalculator;
  32. import net.sf.l2j.gameserver.serverpackets.SystemMessage;
  33. import net.sf.l2j.gameserver.templates.L2ArmorType;
  34. import net.sf.l2j.gameserver.templates.L2Item;
  35. import net.sf.l2j.gameserver.templates.L2Weapon;
  36. import net.sf.l2j.gameserver.templates.L2WeaponType;
  37. import net.sf.l2j.gameserver.util.FloodProtector;
  38. /**
  39. * This class ...
  40. *
  41. * @version $Revision: 1.18.2.7.2.9 $ $Date: 2005/03/27 15:29:30 $
  42. */
  43. public final class UseItem extends L2GameClientPacket
  44. {
  45. private static Logger _log = Logger.getLogger(UseItem.class.getName());
  46. private static final String _C__14_USEITEM = "[C] 14 UseItem";
  47. private int _objectId;
  48. @Override
  49. protected void readImpl()
  50. {
  51. _objectId = readD();
  52. }
  53. @Override
  54. protected void runImpl()
  55. {
  56. L2PcInstance activeChar = getClient().getActiveChar();
  57. if (activeChar == null)
  58. return;
  59. // Flood protect UseItem
  60. if (!FloodProtector.getInstance().tryPerformAction(activeChar.getObjectId(), FloodProtector.PROTECTED_USEITEM))
  61. return;
  62. if (activeChar.getPrivateStoreType() != 0)
  63. {
  64. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_TRADE_DISCARD_DROP_ITEM_WHILE_IN_SHOPMODE));
  65. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  66. return;
  67. }
  68. // NOTE: disabled due to deadlocks
  69. // synchronized (activeChar.getInventory())
  70. // {
  71. L2ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
  72. if (item == null)
  73. return;
  74. if (item.isWear())
  75. {
  76. // No unequipping wear-items
  77. return;
  78. }
  79. if (item.getItem().getType2() == L2Item.TYPE2_QUEST)
  80. {
  81. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_USE_QUEST_ITEMS);
  82. activeChar.sendPacket(sm);
  83. sm = null;
  84. return;
  85. }
  86. int itemId = item.getItemId();
  87. /*
  88. * Alt game - Karma punishment // SOE
  89. * 736 Scroll of Escape
  90. * 1538 Blessed Scroll of Escape
  91. * 1829 Scroll of Escape: Clan Hall
  92. * 1830 Scroll of Escape: Castle
  93. * 3958 L2Day - Blessed Scroll of Escape
  94. * 5858 Blessed Scroll of Escape: Clan Hall
  95. * 5859 Blessed Scroll of Escape: Castle
  96. * 6663 Scroll of Escape: Orc Village
  97. * 6664 Scroll of Escape: Silenos Village
  98. * 7117 Scroll of Escape to Talking Island
  99. * 7118 Scroll of Escape to Elven Village
  100. * 7119 Scroll of Escape to Dark Elf Village
  101. * 7120 Scroll of Escape to Orc Village
  102. * 7121 Scroll of Escape to Dwarven Village
  103. * 7122 Scroll of Escape to Gludin Village
  104. * 7123 Scroll of Escape to the Town of Gludio
  105. * 7124 Scroll of Escape to the Town of Dion
  106. * 7125 Scroll of Escape to Floran
  107. * 7126 Scroll of Escape to Giran Castle Town
  108. * 7127 Scroll of Escape to Hardin's Private Academy
  109. * 7128 Scroll of Escape to Heine
  110. * 7129 Scroll of Escape to the Town of Oren
  111. * 7130 Scroll of Escape to Ivory Tower
  112. * 7131 Scroll of Escape to Hunters Village
  113. * 7132 Scroll of Escape to Aden Castle Town
  114. * 7133 Scroll of Escape to the Town of Goddard
  115. * 7134 Scroll of Escape to the Rune Township
  116. * 7135 Scroll of Escape to the Town of Schuttgart.
  117. * 7554 Scroll of Escape to Talking Island
  118. * 7555 Scroll of Escape to Elven Village
  119. * 7556 Scroll of Escape to Dark Elf Village
  120. * 7557 Scroll of Escape to Orc Village
  121. * 7558 Scroll of Escape to Dwarven Village
  122. * 7559 Scroll of Escape to Giran Castle Town
  123. * 7618 Scroll of Escape - Ketra Orc Village
  124. * 7619 Scroll of Escape - Varka Silenos Village
  125. * 10129 Scroll of Escape : Fortress
  126. * 10130 Blessed Scroll of Escape : Fortress
  127. */
  128. if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TELEPORT && activeChar.getKarma() > 0
  129. && (itemId == 736 || itemId == 1538 || itemId == 1829 || itemId == 1830
  130. || itemId == 3958 || itemId == 5858 || itemId == 5859 || itemId == 6663
  131. || itemId == 6664 || (itemId >= 7117 && itemId <= 7135)
  132. || (itemId >= 7554 && itemId <= 7559) || itemId == 7618 || itemId == 7619
  133. || itemId == 10129 || itemId == 10130))
  134. return;
  135. L2Clan cl = activeChar.getClan();
  136. //A shield that can only be used by the members of a clan that owns a castle.
  137. if ((cl == null||cl.getHasCastle() == 0) && itemId == 7015 && Config.CASTLE_SHIELD)
  138. {
  139. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  140. activeChar.sendPacket(sm);
  141. sm = null;
  142. return;
  143. }
  144. //A shield that can only be used by the members of a clan that owns a clan hall.
  145. if ((cl == null|| cl.getHasHideout() == 0) && itemId == 6902 && Config.CLANHALL_SHIELD)
  146. {
  147. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  148. activeChar.sendPacket(sm);
  149. sm = null;
  150. return;
  151. }
  152. //Apella armor used by clan members may be worn by a Baron or a higher level Aristocrat.
  153. if ((itemId >=7860 && itemId <=7879) && Config.APELLA_ARMORS && (cl == null||activeChar.getPledgeClass() < 5))
  154. {
  155. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  156. activeChar.sendPacket(sm);
  157. sm = null;
  158. return;
  159. }
  160. //Clan Oath armor used by all clan members
  161. if ((itemId >=7850 && itemId <=7859) && Config.OATH_ARMORS && (cl == null))
  162. {
  163. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  164. activeChar.sendPacket(sm);
  165. sm = null;
  166. return;
  167. }
  168. //The Lord's Crown used by castle lords only
  169. if (itemId ==6841 && Config.CASTLE_CROWN && (cl == null||(cl.getHasCastle() == 0||!activeChar.isClanLeader())))
  170. {
  171. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  172. activeChar.sendPacket(sm);
  173. sm = null;
  174. return;
  175. }
  176. //Castle circlets used by the members of a clan that owns a castle, academy members are excluded.
  177. if (Config.CASTLE_CIRCLETS &&((itemId >= 6834 && itemId <= 6840)||itemId == 8182||itemId == 8183))
  178. {
  179. if (cl ==null)
  180. {
  181. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  182. activeChar.sendPacket(sm);
  183. sm = null;
  184. return;
  185. }
  186. else
  187. {
  188. int circletId = CastleManager.getInstance().getCircletByCastleId(cl.getHasCastle());
  189. if (activeChar.getPledgeType() == -1||circletId != itemId)
  190. {
  191. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  192. activeChar.sendPacket(sm);
  193. sm = null;
  194. return;
  195. }
  196. }
  197. }
  198. // Items that cannot be used
  199. if (itemId == 57)
  200. return;
  201. if (activeChar.isFishing() && (itemId < 6535 || itemId > 6540))
  202. {
  203. // You cannot do anything else while fishing
  204. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
  205. getClient().getActiveChar().sendPacket(sm);
  206. sm = null;
  207. return;
  208. }
  209. // Char cannot use item when dead
  210. if (activeChar.isDead())
  211. {
  212. SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
  213. sm.addItemName(item);
  214. getClient().getActiveChar().sendPacket(sm);
  215. sm = null;
  216. return;
  217. }
  218. // Char cannot use pet items
  219. if (item.getItem().isForWolf() || item.getItem().isForGreatWolf() || item.getItem().isForHatchling() || item.getItem().isForStrider() || item.getItem().isForBabyPet())
  220. {
  221. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_PET_ITEM); // You cannot equip a pet item.
  222. sm.addItemName(item);
  223. getClient().getActiveChar().sendPacket(sm);
  224. sm = null;
  225. return;
  226. }
  227. if (Config.DEBUG)
  228. _log.finest(activeChar.getObjectId() + ": use item " + _objectId);
  229. if (item.isEquipable())
  230. {
  231. // No unequipping/equipping while the player is in special conditions
  232. if (activeChar.isStunned() || activeChar.isSleeping() || activeChar.isParalyzed()
  233. || activeChar.isAlikeDead())
  234. {
  235. activeChar.sendMessage("Your status does not allow you to do that.");
  236. return;
  237. }
  238. switch (item.getItem().getBodyPart())
  239. {
  240. case L2Item.SLOT_LR_HAND:
  241. case L2Item.SLOT_L_HAND:
  242. case L2Item.SLOT_R_HAND:
  243. {
  244. // Prevent player to remove the weapon on special conditions
  245. if (activeChar.isCastingNow())
  246. {
  247. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_ITEM_WHILE_USING_MAGIC));
  248. return;
  249. }
  250. if ((activeChar.isAttackingNow() || activeChar.isMounted()))
  251. return;
  252. if (activeChar.isDisarmed())
  253. {
  254. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  255. return;
  256. }
  257. // Don't allow weapon/shield equipment if a cursed weapon is equiped
  258. if (activeChar.isCursedWeaponEquipped())
  259. {
  260. return;
  261. }
  262. // Don't allow weapon/shield hero equipment during Olympiads
  263. if (activeChar.isInOlympiadMode() && (item.isHeroItem() || item.isOlyRestrictedItem()))
  264. {
  265. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  266. return;
  267. }
  268. // Don't allow other Race to Wear Kamael exclusive Weapons.
  269. if (!item.isEquipped() && item.getItem() instanceof L2Weapon && !activeChar.isGM())
  270. {
  271. L2Weapon wpn = (L2Weapon)item.getItem();
  272. switch (activeChar.getRace())
  273. {
  274. case Kamael:
  275. {
  276. switch (wpn.getItemType())
  277. {
  278. case NONE:
  279. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  280. return;
  281. }
  282. break;
  283. }
  284. case Human:
  285. case Dwarf:
  286. case Elf:
  287. case DarkElf:
  288. case Orc:
  289. {
  290. switch (wpn.getItemType())
  291. {
  292. case RAPIER:
  293. case CROSSBOW:
  294. case ANCIENT_SWORD:
  295. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  296. return;
  297. }
  298. break;
  299. }
  300. }
  301. }
  302. break;
  303. }
  304. case L2Item.SLOT_CHEST:
  305. case L2Item.SLOT_BACK:
  306. case L2Item.SLOT_GLOVES:
  307. case L2Item.SLOT_FEET:
  308. case L2Item.SLOT_HEAD:
  309. case L2Item.SLOT_FULL_ARMOR:
  310. case L2Item.SLOT_LEGS:
  311. {
  312. if (activeChar.getRace() == Race.Kamael &&
  313. (item.getItem().getItemType() == L2ArmorType.HEAVY
  314. ||item.getItem().getItemType() == L2ArmorType.MAGIC))
  315. {
  316. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  317. return;
  318. }
  319. break;
  320. }
  321. //Race circlets can be used only if your race is matching.
  322. case L2Item.SLOT_HAIRALL:
  323. {
  324. if (itemId >= 9391 && itemId <= 9396)
  325. {
  326. switch (activeChar.getRace())
  327. {
  328. case Kamael:
  329. {
  330. if (itemId != 9396)
  331. {
  332. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  333. return;
  334. }
  335. break;
  336. }
  337. case Human:
  338. {
  339. if (itemId != 9391)
  340. {
  341. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  342. return;
  343. }
  344. break;
  345. }
  346. case Dwarf:
  347. {
  348. if (itemId != 9395)
  349. {
  350. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  351. return;
  352. }
  353. break;
  354. }
  355. case Elf:
  356. {
  357. if (itemId != 9392)
  358. {
  359. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  360. return;
  361. }
  362. break;
  363. }
  364. case DarkElf:
  365. {
  366. if (itemId != 9393)
  367. {
  368. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  369. return;
  370. }
  371. break;
  372. }
  373. case Orc:
  374. {
  375. if (itemId != 9394)
  376. {
  377. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  378. return;
  379. }
  380. break;
  381. }
  382. }
  383. }
  384. }
  385. case L2Item.SLOT_L_BRACELET:
  386. {
  387. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  388. if ((item.getItemId() >= 9605 && item.getItemId() <= 9615)||item.getItemId() == 10018)
  389. {
  390. if (activeChar.getClan()!= null)
  391. {
  392. switch (item.getItemId())
  393. {
  394. case 9605:
  395. if (activeChar.getClan().getHasHideout() != 62)
  396. {
  397. activeChar.sendPacket(sm);
  398. return;
  399. }
  400. break;
  401. case 9606:
  402. if (activeChar.getClan().getHasHideout() != 63)
  403. {
  404. activeChar.sendPacket(sm);
  405. return;
  406. }
  407. break;
  408. case 9607:
  409. if (activeChar.getClan().getHasCastle() != 1)
  410. {
  411. activeChar.sendPacket(sm);
  412. return;
  413. }
  414. break;
  415. case 9608:
  416. if (activeChar.getClan().getHasCastle() != 2)
  417. {
  418. activeChar.sendPacket(sm);
  419. return;
  420. }
  421. break;
  422. case 9609:
  423. if (activeChar.getClan().getHasCastle() != 3)
  424. {
  425. activeChar.sendPacket(sm);
  426. return;
  427. }
  428. break;
  429. case 9610:
  430. if (activeChar.getClan().getHasCastle() != 4)
  431. {
  432. activeChar.sendPacket(sm);
  433. return;
  434. }
  435. break;
  436. case 9611:
  437. if (activeChar.getClan().getHasCastle() != 5)
  438. {
  439. activeChar.sendPacket(sm);
  440. return;
  441. }
  442. break;
  443. case 9612:
  444. if (activeChar.getClan().getHasCastle() != 6)
  445. {
  446. activeChar.sendPacket(sm);
  447. return;
  448. }
  449. break;
  450. case 9613:
  451. if (activeChar.getClan().getHasCastle() != 7)
  452. {
  453. activeChar.sendPacket(sm);
  454. return;
  455. }
  456. break;
  457. case 9614:
  458. if (activeChar.getClan().getHasCastle() != 8)
  459. {
  460. activeChar.sendPacket(sm);
  461. return;
  462. }
  463. break;
  464. case 9615:
  465. if (activeChar.getClan().getHasCastle() != 9)
  466. {
  467. activeChar.sendPacket(sm);
  468. return;
  469. }
  470. break;
  471. case 10018:
  472. if (activeChar.getClan().getHasFort() == 0)
  473. {
  474. activeChar.sendPacket(sm);
  475. return;
  476. }
  477. break;
  478. }
  479. }
  480. else
  481. {
  482. activeChar.sendPacket(sm);
  483. return;
  484. }
  485. }
  486. }
  487. }
  488. if (activeChar.isCursedWeaponEquipped() && itemId == 6408) // Don't allow to put formal wear
  489. {
  490. return;
  491. }
  492. // Equip or unEquip
  493. L2ItemInstance[] items = null;
  494. boolean isEquiped = item.isEquipped();
  495. SystemMessage sm = null;
  496. L2ItemInstance old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
  497. if (old == null)
  498. old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  499. activeChar.checkSSMatch(item, old);
  500. if (isEquiped)
  501. {
  502. if (item.getEnchantLevel() > 0)
  503. {
  504. sm = new SystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
  505. sm.addNumber(item.getEnchantLevel());
  506. sm.addItemName(item);
  507. }
  508. else
  509. {
  510. sm = new SystemMessage(SystemMessageId.S1_DISARMED);
  511. sm.addItemName(item);
  512. }
  513. activeChar.sendPacket(sm);
  514. int slot = activeChar.getInventory().getSlotFromItem(item);
  515. items = activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
  516. }
  517. else
  518. {
  519. int tempBodyPart = item.getItem().getBodyPart();
  520. L2ItemInstance tempItem = activeChar.getInventory().getPaperdollItemByL2ItemId(tempBodyPart);
  521. //check if the item replaces a wear-item
  522. if (tempItem != null && tempItem.isWear())
  523. {
  524. // dont allow an item to replace a wear-item
  525. return;
  526. }
  527. else if (tempBodyPart == 0x4000) // left+right hand equipment
  528. {
  529. // this may not remove left OR right hand equipment
  530. tempItem = activeChar.getInventory().getPaperdollItem(7);
  531. if (tempItem != null && tempItem.isWear()) return;
  532. tempItem = activeChar.getInventory().getPaperdollItem(8);
  533. if (tempItem != null && tempItem.isWear()) return;
  534. }
  535. else if (tempBodyPart == 0x8000) // fullbody armor
  536. {
  537. // this may not remove chest or leggins
  538. tempItem = activeChar.getInventory().getPaperdollItem(10);
  539. if (tempItem != null && tempItem.isWear()) return;
  540. tempItem = activeChar.getInventory().getPaperdollItem(11);
  541. if (tempItem != null && tempItem.isWear()) return;
  542. }
  543. if (item.getEnchantLevel() > 0)
  544. {
  545. sm = new SystemMessage(SystemMessageId.S1_S2_EQUIPPED);
  546. sm.addNumber(item.getEnchantLevel());
  547. sm.addItemName(item);
  548. }
  549. else
  550. {
  551. sm = new SystemMessage(SystemMessageId.S1_EQUIPPED);
  552. sm.addItemName(item);
  553. }
  554. activeChar.sendPacket(sm);
  555. items = activeChar.getInventory().equipItemAndRecord(item);
  556. // Consume mana - will start a task if required; returns if item is not a shadow item
  557. item.decreaseMana(false);
  558. }
  559. sm = null;
  560. activeChar.refreshExpertisePenalty();
  561. if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
  562. activeChar.checkIfWeaponIsAllowed();
  563. InventoryUpdate iu = new InventoryUpdate();
  564. iu.addItems(Arrays.asList(items));
  565. activeChar.sendPacket(iu);
  566. activeChar.abortAttack();
  567. activeChar.broadcastUserInfo();
  568. }
  569. else
  570. {
  571. L2Weapon weaponItem = activeChar.getActiveWeaponItem();
  572. int itemid = item.getItemId();
  573. //_log.finest("item not equipable id:"+ item.getItemId());
  574. if (itemid == 4393)
  575. {
  576. activeChar.sendPacket(new ShowCalculator(4393));
  577. }
  578. else if ((weaponItem != null && weaponItem.getItemType() == L2WeaponType.ROD)
  579. && ((itemid >= 6519 && itemid <= 6527) || (itemid >= 7610 && itemid <= 7613) || (itemid >= 7807 && itemid <= 7809) || (itemid >= 8484 && itemid <= 8486) || (itemid >= 8505 && itemid <= 8513)))
  580. {
  581. activeChar.getInventory().setPaperdollItem(Inventory.PAPERDOLL_LHAND, item);
  582. activeChar.broadcastUserInfo();
  583. // Send a Server->Client packet ItemList to this L2PcINstance to update left hand equipement
  584. ItemList il = new ItemList(activeChar, false);
  585. sendPacket(il);
  586. return;
  587. }
  588. else
  589. {
  590. IItemHandler handler = ItemHandler.getInstance().getItemHandler(item.getItemId());
  591. if (handler == null)
  592. {
  593. if (Config.DEBUG)
  594. _log.warning("No item handler registered for item ID " + item.getItemId() + ".");
  595. }
  596. else
  597. handler.useItem(activeChar, item);
  598. }
  599. }
  600. // }
  601. }
  602. @Override
  603. public String getType()
  604. {
  605. return _C__14_USEITEM;
  606. }
  607. }