mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 17:06:16 +00:00
PluginManager: ensure that handler candidates of async events with wrong return types don't attempt to register as sync events
this will cause other, more confusing errors to be thrown. to be honest, I'm not sure if enforcing the return type here is even necessary (or desirable).
This commit is contained in:
@ -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<null> to be able to handle async events");
|
||||
}
|
||||
$this->registerAsyncEvent($eventClass, $handlerClosure, $priority, $plugin, $handleCancelled, $exclusiveCall);
|
||||
}else{
|
||||
$this->registerEvent($eventClass, $handlerClosure, $priority, $plugin, $handleCancelled);
|
||||
|
Reference in New Issue
Block a user