RequestDispel.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server 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 Server 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 com.l2jserver.gameserver.network.clientpackets;
  20. import com.l2jserver.Config;
  21. import com.l2jserver.gameserver.datatables.SkillData;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.model.skills.AbnormalType;
  24. import com.l2jserver.gameserver.model.skills.Skill;
  25. /**
  26. * @author KenM
  27. */
  28. public class RequestDispel extends L2GameClientPacket
  29. {
  30. private static final String _C_D0_4B_REQUESTDISPEL = "[C] D0:4B RequestDispel";
  31. private int _objectId;
  32. private int _skillId;
  33. private int _skillLevel;
  34. @Override
  35. protected void readImpl()
  36. {
  37. _objectId = readD();
  38. _skillId = readD();
  39. _skillLevel = readD();
  40. }
  41. @Override
  42. protected void runImpl()
  43. {
  44. if ((_skillId <= 0) || (_skillLevel <= 0))
  45. {
  46. return;
  47. }
  48. final L2PcInstance activeChar = getClient().getActiveChar();
  49. if (activeChar == null)
  50. {
  51. return;
  52. }
  53. final Skill skill = SkillData.getInstance().getSkill(_skillId, _skillLevel);
  54. if (skill == null)
  55. {
  56. return;
  57. }
  58. if (!skill.canBeDispeled() || skill.isStayAfterDeath() || skill.isDebuff())
  59. {
  60. return;
  61. }
  62. if (skill.getAbnormalType() == AbnormalType.TRANSFORM)
  63. {
  64. return;
  65. }
  66. if (skill.isDance() && !Config.DANCE_CANCEL_BUFF)
  67. {
  68. return;
  69. }
  70. if (activeChar.getObjectId() == _objectId)
  71. {
  72. activeChar.stopSkillEffects(true, _skillId);
  73. }
  74. else
  75. {
  76. if (activeChar.hasSummon() && (activeChar.getSummon().getObjectId() == _objectId))
  77. {
  78. activeChar.getSummon().stopSkillEffects(true, _skillId);
  79. }
  80. }
  81. }
  82. @Override
  83. public String getType()
  84. {
  85. return _C_D0_4B_REQUESTDISPEL;
  86. }
  87. }