pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.27k stars 1.54k forks source link

When cancelling EntityDamageEvent, EntityDamageByEntityEvent is still handled #4281

Closed HashimTheArab closed 3 years ago

HashimTheArab commented 3 years ago

Issue description

Steps to reproduce the issue

  1. cancel EntityDamageEvent
  2. Attack an entity and log something in EntityDamageByEntityEvent

OS and versions

Plugins

Plugins (2): Core v3.2.0, DevTools v1.15.0+dev

Crashdump, backtrace or other files

dktapps commented 3 years ago

Both handlers are receiving the same event instance. The EntityDamageByEntityEvent handler is called first, and then the less specific handler (EntityDamageEvent) later. Therefore this is expected behaviour.

That said, there is no defined order in which these handlers will execute, so you shouldn't depend on this behaviour.

SOF3 commented 3 years ago

If you need one handler to be executed before another, you should use the @priority attribute.