runelynx

Spells won't fire

Jul 26th, 2015
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. @EventHandler(priority = EventPriority.LOWEST)
  2. public void onEntityDamageByEntity(final EntityDamageByEntityEvent edbe) {
  3.  
  4. double newHealthRatio = (((LivingEntity) edbe.getEntity())
  5. .getMaxHealth() - edbe.getDamage())
  6. / ((LivingEntity) edbe.getEntity()).getMaxHealth();
  7.  
  8. // Check if mob is a monster, but not a wither (EnderDragon is not
  9. // Monster)
  10. // and that new health of mob is <15%
  11. // and that player has proper Fate level
  12.  
  13. if (edbe.getEntity() instanceof Monster
  14. && newHealthRatio > 0
  15. && newHealthRatio < 0.15
  16. && !(edbe.getEntity() instanceof Wither)
  17. && faithMap.get(edbe.getDamager().getUniqueId())
  18. .checkEquippedFaithLevel("Fate",
  19. Faith.FATE_INEVITABLE_DEMISE_LEVEL)) {
  20.  
  21. faithMap.get(edbe.getDamager().getUniqueId())
  22. .castFate_InevitableDemise(
  23. edbe.getDamager().getUniqueId(),
  24. ((Player) edbe.getDamager()),
  25. ((LivingEntity) edbe.getEntity()));
  26.  
  27. }
  28.  
  29.  
  30. // Check if entity is a PLAYER
  31. // and that new health of player is 0
  32. // and that player has proper Fate level
  33.  
  34. if (edbe.getEntity() instanceof Player
  35. && (edbe.getDamage() > ((Player) edbe.getEntity()).getHealth())
  36. && faithMap.get(((Player) edbe.getEntity()).getUniqueId())
  37. .checkEquippedFaithLevel("Time",
  38. Faith.TIME_REWIND_LEVEL)) {
  39. faithMap.get(((Player) edbe.getEntity()).getUniqueId()).castTime_Rewind(
  40. ((Player) edbe.getEntity()));
  41. edbe.setCancelled(true);
  42.  
  43. }
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment