mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +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:
parent
ac1cf73f8e
commit
972a9fb201
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user