From 1abb8f178390c8eaf6eeca3b45ac27a6f547d050 Mon Sep 17 00:00:00 2001 From: Dries C Date: Wed, 27 Mar 2024 11:35:23 +0100 Subject: [PATCH] Update composer name to nethergamesmc/libasynql --- composer.json | 7 +++++-- .../src/poggit/libasynql/CoreConstants.php | 20 +++++++++++++++++++ .../poggit/libasynql/base/SqlSlaveThread.php | 16 ++++++++++++--- libasynql/src/poggit/libasynql/libasynql.php | 4 +++- 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 libasynql/src/poggit/libasynql/CoreConstants.php diff --git a/composer.json b/composer.json index 10417526..63e9734b 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,11 @@ { - "name": "sof3/libasynql", + "name": "nethergamesmc/libasynql", "type": "library", "require": { "sof3/await-generator": "^2.0.0 || ^3.0.0" }, "require-dev": { - "pocketmine/pocketmine-mp": "^5.0.0-BETA4" + "nethergamesmc/pocketmine-mp": "dev-stable" }, "license": "Apache-2.0", "autoload": { @@ -19,6 +19,9 @@ "email": "sofe2038@gmail.com" } ], + "repositories": [ + { "type": "vcs", "url": "git@github.com:NetherGamesMC/PocketMine-MP.git" } + ], "bin": [ "libasynql/cli/def.php", "libasynql/cli/fx.php" diff --git a/libasynql/src/poggit/libasynql/CoreConstants.php b/libasynql/src/poggit/libasynql/CoreConstants.php new file mode 100644 index 00000000..3e93e441 --- /dev/null +++ b/libasynql/src/poggit/libasynql/CoreConstants.php @@ -0,0 +1,20 @@ +getPluginManager()->getPlugin("DEVirion")->getVirionClassLoader(); - $this->setClassLoaders([Server::getInstance()->getLoader(), $cl]); + /** @var ?ClassLoader $cl */ + $cl = Server::getInstance()->getPluginManager()->getPlugin("DEVirion")?->getVirionClassLoader(); + if($cl === null){ + $this->autoloaderPath = COMPOSER_AUTOLOADER_PATH; + }else{ + $this->setClassLoaders([Server::getInstance()->getLoader(), $cl]); + } } $this->start(NativeThread::INHERIT_INI); } protected function onRun() : void{ + if ($this->autoloaderPath !== null) { + require $this->autoloaderPath; + } + $error = $this->createConn($resource); $this->connCreated = true; $this->connError = $error; diff --git a/libasynql/src/poggit/libasynql/libasynql.php b/libasynql/src/poggit/libasynql/libasynql.php index 94fd59e6..7b7720e7 100644 --- a/libasynql/src/poggit/libasynql/libasynql.php +++ b/libasynql/src/poggit/libasynql/libasynql.php @@ -40,6 +40,8 @@ use function strtolower; use function usleep; +require_once 'CoreConstants.php'; + /** * An utility class providing convenient access to the API */ @@ -144,7 +146,7 @@ public static function create(PluginBase $plugin, $configData, array $sqlMap, bo throw new SqlError(SqlError::STAGE_CONNECT, $pool->getConnError()); } - $connector = new DataConnectorImpl($plugin, $pool, $placeHolder, $logQueries ?? !libasynql::isPackaged()); + $connector = new DataConnectorImpl($plugin, $pool, $placeHolder, $logQueries ?? false); foreach(is_string($sqlMap[$dialect]) ? [$sqlMap[$dialect]] : $sqlMap[$dialect] as $file){ $resource = $plugin->getResource($file); if($resource===null){