From 05a42712bf670c68872e7bb9cabf9bb6cc0d78c0 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 1 Apr 2014 04:59:44 +0200 Subject: [PATCH] Added non-packaged plugins & pocketmine warnings --- src/PocketMine/PocketMine.php | 3 +++ src/PocketMine/plugin/FolderPluginLoader.php | 7 ++++--- src/PocketMine/plugin/PharPluginLoader.php | 6 +++--- start.cmd | 8 ++++---- start.sh | 6 +++--- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/PocketMine/PocketMine.php b/src/PocketMine/PocketMine.php index a80bb5bc7..3b62ba6fd 100644 --- a/src/PocketMine/PocketMine.php +++ b/src/PocketMine/PocketMine.php @@ -356,6 +356,9 @@ namespace pocketmine { new Installer(); } + if(substr(__FILE__, 0, 7) !== "phar"){ + console("[WARNING] Non-packaged PocketMine-MP installation detected, do not use on production."); + } $server = new Server($autoloader, \pocketmine\PATH, \pocketmine\DATA, \pocketmine\PLUGIN_PATH); $server->start(); diff --git a/src/PocketMine/plugin/FolderPluginLoader.php b/src/PocketMine/plugin/FolderPluginLoader.php index 00a0ffde4..0745ac344 100644 --- a/src/PocketMine/plugin/FolderPluginLoader.php +++ b/src/PocketMine/plugin/FolderPluginLoader.php @@ -50,7 +50,8 @@ class FolderPluginLoader implements PluginLoader{ public function loadPlugin($file){ if(is_dir($file) and file_exists($file . "/plugin.yml") and file_exists($file . "/src/")){ if(($description = $this->getPluginDescription($file)) instanceof PluginDescription){ - console("[INFO] Loading " . $description->getName()); + console("[INFO] Loading " . $description->getFullName()); + console("[WARNING] Non-packaged plugin ".$description->getName() ." detected, do not use on production."); $dataFolder = dirname($file) . DIRECTORY_SEPARATOR . $description->getName(); if(file_exists($dataFolder) and !is_dir($dataFolder)){ trigger_error("Projected dataFolder '" . $dataFolder . "' for " . $description->getName() . " exists and is not a directory", E_USER_WARNING); @@ -123,7 +124,7 @@ class FolderPluginLoader implements PluginLoader{ */ public function enablePlugin(Plugin $plugin){ if($plugin instanceof PluginBase and !$plugin->isEnabled()){ - console("[INFO] Enabling " . $plugin->getDescription()->getName()); + console("[INFO] Enabling " . $plugin->getDescription()->getFullName()); $plugin->setEnabled(true); @@ -136,7 +137,7 @@ class FolderPluginLoader implements PluginLoader{ */ public function disablePlugin(Plugin $plugin){ if($plugin instanceof PluginBase and $plugin->isEnabled()){ - console("[INFO] Disabling " . $plugin->getDescription()->getName()); + console("[INFO] Disabling " . $plugin->getDescription()->getFullName()); Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin)); diff --git a/src/PocketMine/plugin/PharPluginLoader.php b/src/PocketMine/plugin/PharPluginLoader.php index 169516ca8..f1f14f04b 100644 --- a/src/PocketMine/plugin/PharPluginLoader.php +++ b/src/PocketMine/plugin/PharPluginLoader.php @@ -49,7 +49,7 @@ class PharPluginLoader implements PluginLoader{ */ public function loadPlugin($file){ if(\Phar::isValidPharFilename($file) and ($description = $this->getPluginDescription($file)) instanceof PluginDescription){ - console("[INFO] Loading " . $description->getName()); + console("[INFO] Loading " . $description->getFullName()); $dataFolder = dirname($file) . DIRECTORY_SEPARATOR . $description->getName(); if(file_exists($dataFolder) and !is_dir($dataFolder)){ trigger_error("Projected dataFolder '" . $dataFolder . "' for " . $description->getName() . " exists and is not a directory", E_USER_WARNING); @@ -122,7 +122,7 @@ class PharPluginLoader implements PluginLoader{ */ public function enablePlugin(Plugin $plugin){ if($plugin instanceof PluginBase and !$plugin->isEnabled()){ - console("[INFO] Enabling " . $plugin->getDescription()->getName()); + console("[INFO] Enabling " . $plugin->getDescription()->getFullName()); $plugin->setEnabled(true); @@ -135,7 +135,7 @@ class PharPluginLoader implements PluginLoader{ */ public function disablePlugin(Plugin $plugin){ if($plugin instanceof PluginBase and $plugin->isEnabled()){ - console("[INFO] Disabling " . $plugin->getDescription()->getName()); + console("[INFO] Disabling " . $plugin->getDescription()->getFullName()); Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin)); diff --git a/start.cmd b/start.cmd index 61390b088..0ded0adaf 100644 --- a/start.cmd +++ b/start.cmd @@ -7,11 +7,11 @@ if exist bin\php\php.exe ( set PHP_BINARY=php ) -if exist src\pocketmine\PocketMine.php ( - set POCKETMINE_FILE=src\pocketmine\PocketMine.php +if exist PocketMine-MP.phar ( + set POCKETMINE_FILE=PocketMine-MP.phar ) else ( - if exist PocketMine-MP.phar ( - set POCKETMINE_FILE=PocketMine-MP.phar + if exist src\pocketmine\PocketMine.php ( + set POCKETMINE_FILE=src\pocketmine\PocketMine.php ) else ( echo "Couldn't find a valid PocketMine-MP installation" pause diff --git a/start.sh b/start.sh index b427aa26f..661ff416a 100755 --- a/start.sh +++ b/start.sh @@ -34,10 +34,10 @@ if [ "$PHP_BINARY" == "" ]; then fi if [ "$POCKETMINE_FILE" == "" ]; then - if [ -f ./src/PocketMine/PocketMine.php ]; then - POCKETMINE_FILE="./src/pocketmine/PocketMine.php" - elif [ -f ./PocketMine-MP.phar ]; then + if [ -f ./PocketMine-MP.phar ]; then POCKETMINE_FILE="./PocketMine-MP.phar" + elif [ -f ./src/PocketMine/PocketMine.php ]; then + POCKETMINE_FILE="./src/pocketmine/PocketMine.php" else echo "Couldn't find a valid PocketMine-MP installation" exit 1