diff --git a/src/pocketmine/scheduler/AsyncWorker.php b/src/pocketmine/scheduler/AsyncWorker.php index 81e313821..7b8532feb 100644 --- a/src/pocketmine/scheduler/AsyncWorker.php +++ b/src/pocketmine/scheduler/AsyncWorker.php @@ -38,9 +38,7 @@ class AsyncWorker extends Worker{ public function run(){ $this->registerClassLoader(); - if(MainLogger::getLogger() === null){ - $this->logger->registerStatic(); - } + $this->logger->registerStatic(); gc_enable(); ini_set("memory_limit", '-1'); diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index 3cad79782..818e7976a 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -54,22 +54,22 @@ class MainLogger extends \AttachableThreadedLogger{ } /** - * @return MainLogger|null + * @return MainLogger */ - public static function getLogger(){ + public static function getLogger() : MainLogger{ return static::$logger; } /** - * Assigns the MainLogger instance to the {@link MainLogger#logger} static property. Because static properties are - * thread-local, this must be called from the body of every Thread if you want the logger to be accessible via - * {@link MainLogger#getLogger}. + * Assigns the MainLogger instance to the {@link MainLogger#logger} static property. + * + * WARNING: Because static properties are thread-local, this MUST be called from the body of every Thread if you + * want the logger to be accessible via {@link MainLogger#getLogger}. */ public function registerStatic(){ - if(static::$logger instanceof MainLogger){ - throw new \RuntimeException("MainLogger has been already registered"); + if(static::$logger === null){ + static::$logger = $this; } - static::$logger = $this; } public function emergency($message){ diff --git a/tests/plugins/PocketMine-TesterPlugin b/tests/plugins/PocketMine-TesterPlugin index e09e6e945..69608aae7 160000 --- a/tests/plugins/PocketMine-TesterPlugin +++ b/tests/plugins/PocketMine-TesterPlugin @@ -1 +1 @@ -Subproject commit e09e6e945db84f07050ccadc54463e8beb8e32ba +Subproject commit 69608aae7e95f003c9c02b1830705af8e9f82015