BeastSpice.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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.datatables.SkillTable;
  17. import net.sf.l2j.gameserver.handler.IItemHandler;
  18. import net.sf.l2j.gameserver.model.L2ItemInstance;
  19. import net.sf.l2j.gameserver.model.L2Object;
  20. import net.sf.l2j.gameserver.model.actor.instance.L2FeedableBeastInstance;
  21. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
  23. import net.sf.l2j.gameserver.network.SystemMessageId;
  24. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  25. public class BeastSpice implements IItemHandler
  26. {
  27. // Golden Spice, Crystal Spice
  28. private static final int[] ITEM_IDS =
  29. {
  30. 6643, 6644
  31. };
  32. /**
  33. *
  34. * @see net.sf.l2j.gameserver.handler.IItemHandler#useItem(net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance, net.sf.l2j.gameserver.model.L2ItemInstance)
  35. */
  36. public void useItem(L2PlayableInstance playable, L2ItemInstance item)
  37. {
  38. if (!(playable instanceof L2PcInstance))
  39. return;
  40. L2PcInstance activeChar = (L2PcInstance) playable;
  41. if (!(activeChar.getTarget() instanceof L2FeedableBeastInstance))
  42. {
  43. activeChar.sendPacket(new SystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
  44. return;
  45. }
  46. L2Object[] targets = new L2Object[1];
  47. targets[0] = activeChar.getTarget();
  48. int itemId = item.getItemId();
  49. if (itemId == 6643)
  50. { // Golden Spice
  51. activeChar.useMagic(SkillTable.getInstance().getInfo(2188, 1), false, false);
  52. }
  53. else if (itemId == 6644)
  54. { // Crystal Spice
  55. activeChar.useMagic(SkillTable.getInstance().getInfo(2189, 1), false, false);
  56. }
  57. }
  58. /**
  59. *
  60. * @see net.sf.l2j.gameserver.handler.IItemHandler#getItemIds()
  61. */
  62. public int[] getItemIds()
  63. {
  64. return ITEM_IDS;
  65. }
  66. }