Recall.java 3.4 KB

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