one of the plugin's main work is once we register a listener to listen the even happen and do something. https://github.com/PocketMine/SimpleAuth/blob/master/src/SimpleAuth/SimpleAuth.php#L366 ,like: PHP: $this->listener = new EventListener($this); $this->getServer()->getPluginManager()->registerEvents($this->listener, $this); the pocketmine-pm use the pocketmine\plugin\PluginManager::registerEvents to register the event by the parameter but it will throw a error if you use the second function. you can only use EntityDamageEvent not EntityDamageByEntityEvent, PHP: public function onEntityDamage(EntityDamageEvent $event){ if($event instanceof EntityDamageByEntityEvent){ //you can do EntityDamageByEntityEvent event here } if($event->getEntity() instanceof Player and !$this->plugin->isPlayerAuthenticated($event->getEntity())){ $event->setCancelled(true); } } public function EntityDamageByEntityEvent(EntityDamageByEntityEvent $event){ if(($event->getEntity() instanceof Player and !$this->plugin->isPlayerAuthenticated($event->getEntity())) or ($event->getDamager() instanceof Player and !$this->plugin->isPlayerAuthenticated($event->getDamager()))){ $event->setCancelled(true); } } because: pocketmine-pm call the plugins event use pocketmine\plugin\PluginManager::callEvent(Event $event); PHP: public function callEvent(Event $event){ foreach($event->getHandlers()->getRegisteredListeners() as $registration){//...}} we found $event->getHandlers() is to get public static $handlerList = null; but class EntityDamageByEntityEvent extends EntityDamageEvent so we can onlye call a EntityDamageEvent. you can only use the event witch have ,children just judge.
In simple words, you should only register event handlers for events that have the PHP: public static $handlerList = null; line in the source code file.
No. EntityDamageByEntityEvent gets called, but it doesn't have its own handler list, and it falls back to the EntityDamageEvent handler list. So in simple words, only hook to events that have their own handler lists.