DodgeEventHandler.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.gmail.nossr50.skills.acrobatics;
  2. import org.bukkit.event.entity.EntityDamageEvent;
  3. import com.gmail.nossr50.datatypes.McMMOPlayer;
  4. import com.gmail.nossr50.locale.LocaleLoader;
  5. import com.gmail.nossr50.skills.utilities.SkillType;
  6. import com.gmail.nossr50.util.Misc;
  7. public class DodgeEventHandler extends AcrobaticsEventHandler {
  8. protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
  9. super(manager, event);
  10. calculateSkillModifier();
  11. calculateModifiedDamage();
  12. }
  13. @Override
  14. protected void calculateSkillModifier() {
  15. this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.dodgeMaxBonusLevel);
  16. }
  17. @Override
  18. protected void calculateModifiedDamage() {
  19. int modifiedDamage = damage / 2;
  20. if (modifiedDamage <= 0) {
  21. modifiedDamage = 1;
  22. }
  23. this.modifiedDamage = modifiedDamage;
  24. }
  25. @Override
  26. protected void modifyEventDamage() {
  27. event.setDamage(modifiedDamage);
  28. }
  29. @Override
  30. protected void sendAbilityMessage() {
  31. manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
  32. }
  33. @Override
  34. protected void processXpGain(int xp) {
  35. McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer();
  36. if (System.currentTimeMillis() >= mcMMOPlayer.getProfile().getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
  37. manager.getMcMMOPlayer().addXp(SkillType.ACROBATICS, xp);
  38. }
  39. }
  40. }