correction of various problems

This commit is contained in:
ShockedPlot7560 2023-10-27 21:45:22 +02:00
parent 7e87fbbb7a
commit 5beaa3ce4e
No known key found for this signature in database
GPG Key ID: D7539B420F1FA86E
4 changed files with 4 additions and 9 deletions

View File

@ -106,7 +106,7 @@ final class AsyncEventDelegate{
$nonConcurrentHandlers = [];
foreach($handlers as $registration){
if($registration instanceof RegisteredAsyncListener){
if($registration->canBeCallConcurrently()){
if($registration->canBeCalledConcurrently()){
$this->promises->add($registration->callAsync($this->event));
}else{
$nonConcurrentHandlers[] = $registration;

View File

@ -26,8 +26,6 @@ namespace pocketmine\event;
use pocketmine\promise\Promise;
trait AsyncEventTrait {
private AsyncEventDelegate $delegate;
/**
* @phpstan-return Promise<null>
*/

View File

@ -142,11 +142,8 @@ class HandlerList{
}
foreach($asyncListenersByPriority as $priority => $asyncListeners){
usort($asyncListeners, static function(RegisteredAsyncListener $a, RegisteredAsyncListener $b) : int{
if($a->canBeCallConcurrently()){
return $b->canBeCallConcurrently() ? 0 : -1;
}else{
return $b->canBeCallConcurrently() ? -1 : 0;
}
// concurrent listeners are sorted to the end of the list
return $b->canBeCalledConcurrently() <=> $a->canBeCalledConcurrently();
});
$listenersByPriority[$priority] = array_merge($listenersByPriority[$priority] ?? [], $asyncListeners);
}

View File

@ -51,7 +51,7 @@ class RegisteredAsyncListener extends RegisteredListener{
parent::__construct($handler, $priority, $plugin, $handleCancelled, $timings);
}
public function canBeCallConcurrently() : bool{
public function canBeCalledConcurrently() : bool{
return !$this->noConcurrentCall;
}