criss28282

Untitled

Jun 25th, 2020
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. /*
  2. * Copyright (C) 2004-2013 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J DataPack is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package handlers.itemhandlers;
  20.  
  21. import java.util.concurrent.TimeUnit;
  22.  
  23. import l2r.gameserver.model.actor.L2Playable;
  24. import l2r.gameserver.model.actor.instance.L2PcInstance;
  25. import l2r.gameserver.model.items.instance.L2ItemInstance;
  26. import l2r.gameserver.network.SystemMessageId;
  27. import l2r.gameserver.util.Util;
  28.  
  29. public class HeroCoin extends ItemSkills
  30. {
  31. @Override
  32. public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
  33. {
  34. if (!playable.isPlayer())
  35. {
  36. playable.sendPacket(SystemMessageId.ITEM_NOT_FOR_PETS);
  37. return false;
  38. }
  39.  
  40. final L2PcInstance activeChar = playable.getActingPlayer();
  41.  
  42. if (activeChar.isHero())
  43. {
  44. activeChar.sendMessage("You cannot use this coin while hero.");
  45. return false;
  46. }
  47. activeChar.setHero(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(30));
  48. activeChar.sendMessage("You received hero for 30 days. Expire at " + Util.convertMillisecondToDate(activeChar.getHeroExpire()));
  49. activeChar.destroyItemByItemId("", 9143, 1, activeChar, true);
  50. return super.useItem(playable, item, forceUse);
  51. }
  52. }
Add Comment
Please, Sign In to add comment