mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 06:25:32 +00:00
correction of various problems
This commit is contained in:
parent
7e87fbbb7a
commit
5beaa3ce4e
@ -106,7 +106,7 @@ final class AsyncEventDelegate{
|
|||||||
$nonConcurrentHandlers = [];
|
$nonConcurrentHandlers = [];
|
||||||
foreach($handlers as $registration){
|
foreach($handlers as $registration){
|
||||||
if($registration instanceof RegisteredAsyncListener){
|
if($registration instanceof RegisteredAsyncListener){
|
||||||
if($registration->canBeCallConcurrently()){
|
if($registration->canBeCalledConcurrently()){
|
||||||
$this->promises->add($registration->callAsync($this->event));
|
$this->promises->add($registration->callAsync($this->event));
|
||||||
}else{
|
}else{
|
||||||
$nonConcurrentHandlers[] = $registration;
|
$nonConcurrentHandlers[] = $registration;
|
||||||
|
@ -26,8 +26,6 @@ namespace pocketmine\event;
|
|||||||
use pocketmine\promise\Promise;
|
use pocketmine\promise\Promise;
|
||||||
|
|
||||||
trait AsyncEventTrait {
|
trait AsyncEventTrait {
|
||||||
private AsyncEventDelegate $delegate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @phpstan-return Promise<null>
|
* @phpstan-return Promise<null>
|
||||||
*/
|
*/
|
||||||
|
@ -142,11 +142,8 @@ class HandlerList{
|
|||||||
}
|
}
|
||||||
foreach($asyncListenersByPriority as $priority => $asyncListeners){
|
foreach($asyncListenersByPriority as $priority => $asyncListeners){
|
||||||
usort($asyncListeners, static function(RegisteredAsyncListener $a, RegisteredAsyncListener $b) : int{
|
usort($asyncListeners, static function(RegisteredAsyncListener $a, RegisteredAsyncListener $b) : int{
|
||||||
if($a->canBeCallConcurrently()){
|
// concurrent listeners are sorted to the end of the list
|
||||||
return $b->canBeCallConcurrently() ? 0 : -1;
|
return $b->canBeCalledConcurrently() <=> $a->canBeCalledConcurrently();
|
||||||
}else{
|
|
||||||
return $b->canBeCallConcurrently() ? -1 : 0;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
$listenersByPriority[$priority] = array_merge($listenersByPriority[$priority] ?? [], $asyncListeners);
|
$listenersByPriority[$priority] = array_merge($listenersByPriority[$priority] ?? [], $asyncListeners);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class RegisteredAsyncListener extends RegisteredListener{
|
|||||||
parent::__construct($handler, $priority, $plugin, $handleCancelled, $timings);
|
parent::__construct($handler, $priority, $plugin, $handleCancelled, $timings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canBeCallConcurrently() : bool{
|
public function canBeCalledConcurrently() : bool{
|
||||||
return !$this->noConcurrentCall;
|
return !$this->noConcurrentCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user