Detection.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 com.l2jserver.gameserver.model.StatsSet;
  21. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  22. import com.l2jserver.gameserver.model.conditions.Condition;
  23. import com.l2jserver.gameserver.model.effects.AbstractEffect;
  24. import com.l2jserver.gameserver.model.skills.AbnormalType;
  25. import com.l2jserver.gameserver.model.skills.BuffInfo;
  26. /**
  27. * @author UnAfraid
  28. */
  29. public class Detection extends AbstractEffect
  30. {
  31. public Detection(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
  32. {
  33. super(attachCond, applyCond, set, params);
  34. }
  35. @Override
  36. public boolean isInstant()
  37. {
  38. return true;
  39. }
  40. @Override
  41. public void onStart(BuffInfo info)
  42. {
  43. super.onStart(info);
  44. if (!info.getEffector().isPlayer() || !info.getEffected().isPlayer())
  45. {
  46. return;
  47. }
  48. final L2PcInstance player = info.getEffector().getActingPlayer();
  49. final L2PcInstance target = info.getEffected().getActingPlayer();
  50. final boolean hasParty = player.isInParty();
  51. final boolean hasClan = player.getClanId() > 0;
  52. final boolean hasAlly = player.getAllyId() > 0;
  53. if (target.getAppearance().getInvisible())
  54. {
  55. if (hasParty && (target.isInParty()) && (player.getParty().getLeaderObjectId() == target.getParty().getLeaderObjectId()))
  56. {
  57. return;
  58. }
  59. else if (hasClan && (player.getClanId() == target.getClanId()))
  60. {
  61. return;
  62. }
  63. else if (hasAlly && (player.getAllyId() == target.getAllyId()))
  64. {
  65. return;
  66. }
  67. // Remove Hide.
  68. target.getEffectList().stopSkillEffects(true, AbnormalType.HIDE);
  69. }
  70. }
  71. }