Recall.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.skillhandlers;
  16. import net.sf.l2j.Config;
  17. import net.sf.l2j.gameserver.datatables.MapRegionTable;
  18. import net.sf.l2j.gameserver.handler.ISkillHandler;
  19. import net.sf.l2j.gameserver.model.L2Character;
  20. import net.sf.l2j.gameserver.model.L2Object;
  21. import net.sf.l2j.gameserver.model.L2Skill;
  22. import net.sf.l2j.gameserver.model.L2Skill.SkillType;
  23. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  24. import net.sf.l2j.gameserver.model.entity.TvTEvent;
  25. import net.sf.l2j.gameserver.network.SystemMessageId;
  26. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  27. import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  28. public class Recall implements ISkillHandler
  29. {
  30. //private static Logger _log = Logger.getLogger(Recall.class.getName());
  31. private static final SkillType[] SKILL_IDS = {SkillType.RECALL};
  32. public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  33. {
  34. if (activeChar instanceof L2PcInstance)
  35. {
  36. // Thanks nbd
  37. if (!TvTEvent.onEscapeUse(((L2PcInstance)activeChar).getObjectId()))
  38. {
  39. ((L2PcInstance)activeChar).sendPacket(ActionFailed.STATIC_PACKET);
  40. return;
  41. }
  42. if (((L2PcInstance)activeChar).isInOlympiadMode())
  43. {
  44. ((L2PcInstance)activeChar).sendPacket(new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
  45. return;
  46. }
  47. }
  48. try
  49. {
  50. for (int index = 0; index < targets.length; index++)
  51. {
  52. if (!(targets[index] instanceof L2Character))
  53. continue;
  54. L2Character target = (L2Character)targets[index];
  55. if (target instanceof L2PcInstance)
  56. {
  57. L2PcInstance targetChar = (L2PcInstance)target;
  58. // Check to see if the current player target is in a festival.
  59. if (targetChar.isFestivalParticipant())
  60. {
  61. targetChar.sendMessage("You may not use an escape skill in a festival.");
  62. continue;
  63. }
  64. // Check to see if player is in jail
  65. if (targetChar.isInJail())
  66. {
  67. targetChar.sendMessage("You can not escape from jail.");
  68. continue;
  69. }
  70. // Check to see if player is in a duel
  71. if (targetChar.isInDuel())
  72. {
  73. targetChar.sendMessage("You cannot use escape skills during a duel.");
  74. continue;
  75. }
  76. }
  77. target.teleToLocation(MapRegionTable.TeleportWhereType.Town);
  78. }
  79. } catch (Throwable e) {
  80. if (Config.DEBUG) e.printStackTrace();
  81. }
  82. }
  83. public SkillType[] getSkillIds()
  84. {
  85. return SKILL_IDS;
  86. }
  87. }