EnchantScrolls.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.handler.itemhandlers;
  16. import net.sf.l2j.gameserver.handler.IItemHandler;
  17. import net.sf.l2j.gameserver.model.L2ItemInstance;
  18. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
  20. import net.sf.l2j.gameserver.network.SystemMessageId;
  21. import net.sf.l2j.gameserver.network.serverpackets.ChooseInventoryItem;
  22. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  23. public class EnchantScrolls implements IItemHandler
  24. {
  25. private static final int[] ITEM_IDS =
  26. {
  27. 729, 730, 731, 732, 6569, 6570, // a grade
  28. 947, 948, 949, 950, 6571, 6572, // b grade
  29. 951, 952, 953, 954, 6573, 6574, // c grade
  30. 955, 956, 957, 958, 6575, 6576, // d grade
  31. 959, 960, 961, 962, 6577, 6578 // s grade
  32. };
  33. /**
  34. *
  35. * @see net.sf.l2j.gameserver.handler.IItemHandler#useItem(net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
  36. */
  37. public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  38. {
  39. if (!(playable instanceof L2PcInstance))
  40. return;
  41. L2PcInstance activeChar = (L2PcInstance) playable;
  42. if (activeChar.isCastingNow())
  43. return;
  44. activeChar.setActiveEnchantItem(item);
  45. activeChar.sendPacket(new SystemMessage(SystemMessageId.SELECT_ITEM_TO_ENCHANT));
  46. activeChar.sendPacket(new ChooseInventoryItem(item.getItemId()));
  47. return;
  48. }
  49. /**
  50. *
  51. * @see net.sf.l2j.gameserver.handler.IItemHandler#getItemIds()
  52. */
  53. public int[] getItemIds()
  54. {
  55. return ITEM_IDS;
  56. }
  57. }