PcBody.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2004-2015 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.targethandlers;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import com.l2jserver.gameserver.handler.ITargetTypeHandler;
  23. import com.l2jserver.gameserver.model.L2Object;
  24. import com.l2jserver.gameserver.model.actor.L2Character;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
  27. import com.l2jserver.gameserver.model.effects.L2EffectType;
  28. import com.l2jserver.gameserver.model.skills.Skill;
  29. import com.l2jserver.gameserver.model.skills.targets.L2TargetType;
  30. import com.l2jserver.gameserver.model.zone.ZoneId;
  31. import com.l2jserver.gameserver.network.SystemMessageId;
  32. /**
  33. * @author UnAfraid
  34. */
  35. public class PcBody implements ITargetTypeHandler
  36. {
  37. @Override
  38. public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
  39. {
  40. List<L2Character> targetList = new ArrayList<>();
  41. if ((target != null) && target.isDead())
  42. {
  43. final L2PcInstance player;
  44. if (activeChar.isPlayer())
  45. {
  46. player = activeChar.getActingPlayer();
  47. }
  48. else
  49. {
  50. player = null;
  51. }
  52. final L2PcInstance targetPlayer;
  53. if (target.isPlayer())
  54. {
  55. targetPlayer = target.getActingPlayer();
  56. }
  57. else
  58. {
  59. targetPlayer = null;
  60. }
  61. final L2PetInstance targetPet;
  62. if (target.isPet())
  63. {
  64. targetPet = (L2PetInstance) target;
  65. }
  66. else
  67. {
  68. targetPet = null;
  69. }
  70. if ((player != null) && ((targetPlayer != null) || (targetPet != null)))
  71. {
  72. boolean condGood = true;
  73. if (skill.hasEffectType(L2EffectType.RESURRECTION))
  74. {
  75. if (targetPlayer != null)
  76. {
  77. // check target is not in a active siege zone
  78. if (targetPlayer.isInsideZone(ZoneId.SIEGE) && !targetPlayer.isInSiege())
  79. {
  80. condGood = false;
  81. activeChar.sendPacket(SystemMessageId.CANNOT_BE_RESURRECTED_DURING_SIEGE);
  82. }
  83. if (targetPlayer.isFestivalParticipant()) // Check to see if the current player target is in a festival.
  84. {
  85. condGood = false;
  86. activeChar.sendMessage("You may not resurrect participants in a festival.");
  87. }
  88. }
  89. }
  90. if (condGood)
  91. {
  92. if (!onlyFirst)
  93. {
  94. targetList.add(target);
  95. return targetList.toArray(new L2Object[targetList.size()]);
  96. }
  97. return new L2Character[]
  98. {
  99. target
  100. };
  101. }
  102. }
  103. }
  104. activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
  105. return EMPTY_TARGET_LIST;
  106. }
  107. @Override
  108. public Enum<L2TargetType> getTargetType()
  109. {
  110. return L2TargetType.PC_BODY;
  111. }
  112. }