ResistSkill.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2004-2014 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.effecthandlers;
  20. import java.util.ArrayList;
  21. import java.util.List;
  22. import com.l2jserver.gameserver.model.StatsSet;
  23. import com.l2jserver.gameserver.model.actor.L2Character;
  24. import com.l2jserver.gameserver.model.conditions.Condition;
  25. import com.l2jserver.gameserver.model.effects.AbstractEffect;
  26. import com.l2jserver.gameserver.model.effects.L2EffectType;
  27. import com.l2jserver.gameserver.model.holders.SkillHolder;
  28. import com.l2jserver.gameserver.model.skills.BuffInfo;
  29. /**
  30. * @author UnAfraid
  31. */
  32. public class ResistSkill extends AbstractEffect
  33. {
  34. private final List<SkillHolder> _skills = new ArrayList<>();
  35. public ResistSkill(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
  36. {
  37. super(attachCond, applyCond, set, params);
  38. if (params != null)
  39. {
  40. for (int i = 1;; i++)
  41. {
  42. int skillId = params.getInt("skillId" + i, 0);
  43. int skillLvl = params.getInt("skillLvl" + i, 0);
  44. if (skillId == 0)
  45. {
  46. break;
  47. }
  48. _skills.add(new SkillHolder(skillId, skillLvl));
  49. }
  50. }
  51. if (_skills.isEmpty())
  52. {
  53. throw new IllegalArgumentException(getClass().getSimpleName() + ": Without parameters!");
  54. }
  55. }
  56. @Override
  57. public void onStart(BuffInfo info)
  58. {
  59. super.onStart(info);
  60. final L2Character effected = info.getEffected();
  61. for (SkillHolder holder : _skills)
  62. {
  63. effected.addInvulAgainst(holder);
  64. effected.sendDebugMessage("Applying invul against " + holder.getSkill());
  65. }
  66. }
  67. @Override
  68. public void onExit(BuffInfo info)
  69. {
  70. final L2Character effected = info.getEffected();
  71. for (SkillHolder holder : _skills)
  72. {
  73. info.getEffected().removeInvulAgainst(holder);
  74. effected.sendDebugMessage("Removing invul against " + holder.getSkill());
  75. }
  76. super.onExit(info);
  77. }
  78. @Override
  79. public L2EffectType getEffectType()
  80. {
  81. return L2EffectType.BUFF;
  82. }
  83. }