UseItem.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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(itemId);
  214. getClient().getActiveChar().sendPacket(sm);
  215. sm = null;
  216. return;
  217. }
  218. // Char cannot use pet items
  219. if (item.getItem().isForWolf() || 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(itemId);
  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 ur 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. }
  336. case Human:
  337. {
  338. if (itemId != 9391)
  339. {
  340. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  341. return;
  342. }
  343. }
  344. case Dwarf:
  345. {
  346. if (itemId != 9395)
  347. {
  348. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  349. return;
  350. };
  351. }
  352. case Elf:
  353. {
  354. if (itemId != 9392)
  355. {
  356. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  357. return;
  358. }
  359. }
  360. case DarkElf:
  361. {
  362. if (itemId != 9393)
  363. {
  364. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  365. return;
  366. }
  367. }
  368. case Orc:
  369. {
  370. if (itemId != 9394)
  371. {
  372. activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION));
  373. return;
  374. }
  375. }
  376. }
  377. break;
  378. }
  379. }
  380. case L2Item.SLOT_L_BRACELET:
  381. {
  382. SystemMessage sm = new SystemMessage(SystemMessageId.CANNOT_EQUIP_ITEM_DUE_TO_BAD_CONDITION);
  383. if ((item.getItemId() >= 9605 && item.getItemId() <= 9615)||item.getItemId() == 10018)
  384. {
  385. if (activeChar.getClan()!= null)
  386. {
  387. switch (item.getItemId())
  388. {
  389. case 9605:
  390. if (activeChar.getClan().getHasHideout() != 62)
  391. {
  392. activeChar.sendPacket(sm);
  393. return;
  394. }
  395. case 9606:
  396. if (activeChar.getClan().getHasHideout() != 63)
  397. {
  398. activeChar.sendPacket(sm);
  399. return;
  400. }
  401. case 9607:
  402. if (activeChar.getClan().getHasCastle() != 1)
  403. {
  404. activeChar.sendPacket(sm);
  405. return;
  406. }
  407. case 9608:
  408. if (activeChar.getClan().getHasCastle() != 2)
  409. {
  410. activeChar.sendPacket(sm);
  411. return;
  412. }
  413. case 9609:
  414. if (activeChar.getClan().getHasCastle() != 3)
  415. {
  416. activeChar.sendPacket(sm);
  417. return;
  418. }
  419. case 9610:
  420. if (activeChar.getClan().getHasCastle() != 4)
  421. {
  422. activeChar.sendPacket(sm);
  423. return;
  424. }
  425. case 9611:
  426. if (activeChar.getClan().getHasCastle() != 5)
  427. {
  428. activeChar.sendPacket(sm);
  429. return;
  430. }
  431. case 9612:
  432. if (activeChar.getClan().getHasCastle() != 6)
  433. {
  434. activeChar.sendPacket(sm);
  435. return;
  436. }
  437. case 9613:
  438. if (activeChar.getClan().getHasCastle() != 7)
  439. {
  440. activeChar.sendPacket(sm);
  441. return;
  442. }
  443. case 9614:
  444. if (activeChar.getClan().getHasCastle() != 8)
  445. {
  446. activeChar.sendPacket(sm);
  447. return;
  448. }
  449. case 9615:
  450. if (activeChar.getClan().getHasCastle() != 9)
  451. {
  452. activeChar.sendPacket(sm);
  453. return;
  454. }
  455. case 10018:
  456. if (activeChar.getClan().getHasFort() == 0)
  457. {
  458. activeChar.sendPacket(sm);
  459. return;
  460. }
  461. }
  462. break;
  463. }
  464. else
  465. {
  466. activeChar.sendPacket(sm);
  467. return;
  468. }
  469. }
  470. }
  471. }
  472. if (activeChar.isCursedWeaponEquipped() && itemId == 6408) // Don't allow to put formal wear
  473. {
  474. return;
  475. }
  476. // Equip or unEquip
  477. L2ItemInstance[] items = null;
  478. boolean isEquiped = item.isEquipped();
  479. SystemMessage sm = null;
  480. L2ItemInstance old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LRHAND);
  481. if (old == null)
  482. old = activeChar.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
  483. activeChar.checkSSMatch(item, old);
  484. if (isEquiped)
  485. {
  486. if (item.getEnchantLevel() > 0)
  487. {
  488. sm = new SystemMessage(SystemMessageId.EQUIPMENT_S1_S2_REMOVED);
  489. sm.addNumber(item.getEnchantLevel());
  490. sm.addItemName(itemId);
  491. }
  492. else
  493. {
  494. sm = new SystemMessage(SystemMessageId.S1_DISARMED);
  495. sm.addItemName(itemId);
  496. }
  497. activeChar.sendPacket(sm);
  498. int slot = activeChar.getInventory().getSlotFromItem(item);
  499. items = activeChar.getInventory().unEquipItemInBodySlotAndRecord(slot);
  500. }
  501. else
  502. {
  503. int tempBodyPart = item.getItem().getBodyPart();
  504. L2ItemInstance tempItem = activeChar.getInventory().getPaperdollItemByL2ItemId(tempBodyPart);
  505. //check if the item replaces a wear-item
  506. if (tempItem != null && tempItem.isWear())
  507. {
  508. // dont allow an item to replace a wear-item
  509. return;
  510. }
  511. else if (tempBodyPart == 0x4000) // left+right hand equipment
  512. {
  513. // this may not remove left OR right hand equipment
  514. tempItem = activeChar.getInventory().getPaperdollItem(7);
  515. if (tempItem != null && tempItem.isWear()) return;
  516. tempItem = activeChar.getInventory().getPaperdollItem(8);
  517. if (tempItem != null && tempItem.isWear()) return;
  518. }
  519. else if (tempBodyPart == 0x8000) // fullbody armor
  520. {
  521. // this may not remove chest or leggins
  522. tempItem = activeChar.getInventory().getPaperdollItem(10);
  523. if (tempItem != null && tempItem.isWear()) return;
  524. tempItem = activeChar.getInventory().getPaperdollItem(11);
  525. if (tempItem != null && tempItem.isWear()) return;
  526. }
  527. if (item.getEnchantLevel() > 0)
  528. {
  529. sm = new SystemMessage(SystemMessageId.S1_S2_EQUIPPED);
  530. sm.addNumber(item.getEnchantLevel());
  531. sm.addItemName(itemId);
  532. }
  533. else
  534. {
  535. sm = new SystemMessage(SystemMessageId.S1_EQUIPPED);
  536. sm.addItemName(itemId);
  537. }
  538. activeChar.sendPacket(sm);
  539. items = activeChar.getInventory().equipItemAndRecord(item);
  540. // Consume mana - will start a task if required; returns if item is not a shadow item
  541. item.decreaseMana(false);
  542. }
  543. sm = null;
  544. activeChar.refreshExpertisePenalty();
  545. if (item.getItem().getType2() == L2Item.TYPE2_WEAPON)
  546. activeChar.checkIfWeaponIsAllowed();
  547. InventoryUpdate iu = new InventoryUpdate();
  548. iu.addItems(Arrays.asList(items));
  549. activeChar.sendPacket(iu);
  550. activeChar.abortAttack();
  551. activeChar.broadcastUserInfo();
  552. }
  553. else
  554. {
  555. L2Weapon weaponItem = activeChar.getActiveWeaponItem();
  556. int itemid = item.getItemId();
  557. //_log.finest("item not equipable id:"+ item.getItemId());
  558. if (itemid == 4393)
  559. {
  560. activeChar.sendPacket(new ShowCalculator(4393));
  561. }
  562. else if ((weaponItem != null && weaponItem.getItemType() == L2WeaponType.ROD)
  563. && ((itemid >= 6519 && itemid <= 6527) || (itemid >= 7610 && itemid <= 7613) || (itemid >= 7807 && itemid <= 7809) || (itemid >= 8484 && itemid <= 8486) || (itemid >= 8505 && itemid <= 8513)))
  564. {
  565. activeChar.getInventory().setPaperdollItem(Inventory.PAPERDOLL_LHAND, item);
  566. activeChar.broadcastUserInfo();
  567. // Send a Server->Client packet ItemList to this L2PcINstance to update left hand equipement
  568. ItemList il = new ItemList(activeChar, false);
  569. sendPacket(il);
  570. return;
  571. }
  572. else
  573. {
  574. IItemHandler handler = ItemHandler.getInstance().getItemHandler(item.getItemId());
  575. if (handler == null)
  576. {
  577. if (Config.DEBUG)
  578. _log.warning("No item handler registered for item ID " + item.getItemId() + ".");
  579. }
  580. else
  581. handler.useItem(activeChar, item);
  582. }
  583. }
  584. // }
  585. }
  586. @Override
  587. public String getType()
  588. {
  589. return _C__14_USEITEM;
  590. }
  591. }