CubicMastery.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package handlers.effecthandlers;
  2. import com.l2jserver.gameserver.model.StatsSet;
  3. import com.l2jserver.gameserver.model.conditions.Condition;
  4. import com.l2jserver.gameserver.model.effects.AbstractEffect;
  5. import com.l2jserver.gameserver.model.skills.BuffInfo;
  6. /**
  7. * Cubic Mastery effect implementation.
  8. * @author Zoey76
  9. */
  10. public final class CubicMastery extends AbstractEffect
  11. {
  12. private final int _cubicCount;
  13. public CubicMastery(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
  14. {
  15. super(attachCond, applyCond, set, params);
  16. _cubicCount = params.getInt("cubicCount", 0);
  17. }
  18. @Override
  19. public boolean canStart(BuffInfo info)
  20. {
  21. return (info.getEffector() != null) && (info.getEffected() != null) && info.getEffected().isPlayer();
  22. }
  23. @Override
  24. public void onStart(BuffInfo info)
  25. {
  26. final int cubicCount = info.getEffected().getActingPlayer().getStat().getMaxCubicCount() + _cubicCount;
  27. info.getEffected().getActingPlayer().getStat().setMaxCubicCount(cubicCount);
  28. }
  29. @Override
  30. public boolean onActionTime(BuffInfo info)
  31. {
  32. return info.getSkill().isPassive();
  33. }
  34. @Override
  35. public void onExit(BuffInfo info)
  36. {
  37. final int cubicCount = info.getEffected().getActingPlayer().getStat().getMaxCubicCount() - _cubicCount;
  38. if (cubicCount <= 0)
  39. {
  40. info.getEffected().getActingPlayer().getStat().setMaxCubicCount(0);
  41. }
  42. else
  43. {
  44. info.getEffected().getActingPlayer().getStat().setMaxCubicCount(cubicCount);
  45. }
  46. }
  47. }