diff --git a/src/plugin/PluginManager.php b/src/plugin/PluginManager.php index afbdf64fd..355d1eeae 100644 --- a/src/plugin/PluginManager.php +++ b/src/plugin/PluginManager.php @@ -654,7 +654,10 @@ class PluginManager{ } } - if(is_subclass_of($eventClass, AsyncEvent::class) && $this->canHandleAsyncEvent($handlerClosure)){ + if(is_subclass_of($eventClass, AsyncEvent::class)){ + if(!$this->canHandleAsyncEvent($handlerClosure)){ + throw new PluginException("Event handler " . Utils::getNiceClosureName($handlerClosure) . " must return null|Promise to be able to handle async events"); + } $this->registerAsyncEvent($eventClass, $handlerClosure, $priority, $plugin, $handleCancelled, $exclusiveCall); }else{ $this->registerEvent($eventClass, $handlerClosure, $priority, $plugin, $handleCancelled);