1.15.2 Cancel Player Attack except LivingEntity.damage()

Discussion in 'Spigot Plugin Development' started by abandoncaptian, Feb 29, 2020.

  1. I'm working on a system that removes ALL attacking from players aside from the damage I manually apply with LivingEntity.Damage(Double, LivingEntity). I would have to call the Entity Damage by Entity event manually with custom arguments. Is there ANY easier way.
     
  2. Why you want to cancel the attack but not the damage :eek:?
     
  3. I want to disable the damage from the player swinging because I'm doing a system where I'm manually applying the damage.
     
  4. Not quite sure what you’re doing, but you can try checking EntityDamageEvent#getCause() to determine why damage was applied.
     
  5. As far as I know EntityDamageByEntity Event doesn't listen to LivingEntity#damage so you should just be able to use that function normally without it being cancelled.
     
  6. it does get called if u provide the Entity that attacked it in the arguments