diff --git a/plugin.yml b/plugin.yml index 66f1070..4f5bbdc 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,10 +1,9 @@ name: DevTools main: DevTools\DevTools -version: 1.8.1 +version: 1.9.0 api: 1.3.1 load: STARTUP author: PocketMine Team -authors: [shoghicp] description: Helps develop and distribute PocketMine-MP plugins website: https://github.com/PocketMine/DevTools commands: diff --git a/src/DevTools/ConsoleScript.php b/src/DevTools/ConsoleScript.php index 10d6409..ad23109 100644 --- a/src/DevTools/ConsoleScript.php +++ b/src/DevTools/ConsoleScript.php @@ -2,7 +2,7 @@ /* * DevTools plugin for PocketMine-MP - * Copyright (C) 2014 PocketMine Team + * Copyright (C) 2014 PocketMine Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,7 +15,7 @@ * GNU General Public License for more details. */ -$opts = getopt("", array("make:", "relative:", "out:", "entry:")); +$opts = getopt("", ["make:", "relative:", "out:", "entry:", "compress"]); if(!isset($opts["make"])){ echo "== PocketMine-MP DevTools CLI interface ==\n\n"; @@ -55,7 +55,7 @@ $maxLen = 0; $count = 0; foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($folderPath)) as $file){ - $path = rtrim(str_replace(array("\\", $relativePath), array("/", ""), $file), "/"); + $path = rtrim(str_replace(["\\", $relativePath], ["/", ""], $file), "/"); if($path{0} === "." or strpos($path, "/.") !== false){ continue; } @@ -65,8 +65,10 @@ } echo "\r[".(++$count)."] ".str_pad($path, $maxLen, " "); } -echo "\nCompressing...\n"; -$phar->compressFiles(\Phar::GZ); +if(isset($opts["compress"])){ + echo "\nCompressing...\n"; + $phar->compressFiles(\Phar::GZ); +} $phar->stopBuffering(); echo "Done!\n"; diff --git a/src/DevTools/DevTools.php b/src/DevTools/DevTools.php index 1564c8a..fb26fc7 100644 --- a/src/DevTools/DevTools.php +++ b/src/DevTools/DevTools.php @@ -2,7 +2,7 @@ /* * DevTools plugin for PocketMine-MP - * Copyright (C) 2014 PocketMine Team + * Copyright (C) 2014 PocketMine Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -39,12 +39,10 @@ public function onLoad(){ public function onEnable(){ @mkdir($this->getDataFolder()); - $this->getServer()->getLoader()->add("FolderPluginLoader", array( - $this->getFile() . "src" - )); + if(!class_exists("FolderPluginLoader\\FolderPluginLoader", false)){ $this->getServer()->getPluginManager()->registerInterface("FolderPluginLoader\\FolderPluginLoader"); - $this->getServer()->getPluginManager()->loadPlugins($this->getServer()->getPluginPath(), array("FolderPluginLoader\\FolderPluginLoader")); + $this->getServer()->getPluginManager()->loadPlugins($this->getServer()->getPluginPath(), ["FolderPluginLoader\\FolderPluginLoader"]); $this->getLogger()->info("Registered folder plugin loader"); $this->getServer()->enablePlugins(PluginLoadOrder::STARTUP); } @@ -116,10 +114,10 @@ private function makePluginLoader(CommandSender $sender, Command $command, $labe "name" => "FolderPluginLoader", "version" => "1.0.0", "main" => "FolderPluginLoader\\Main", - "api" => array("1.0.0"), - "depend" => array(), + "api" => ["1.0.0"], + "depend" => [], "description" => "Loader of folder plugins", - "authors" => array("PocketMine Team"), + "authors" => ["PocketMine Team"], "website" => "https://github.com/PocketMine/DevTools", "creationDate" => time() ]); @@ -179,11 +177,12 @@ private function makePluginCommand(CommandSender $sender, Command $command, $lab $filePath = rtrim(str_replace("\\", "/", $file->getValue($plugin)), "/") . "/"; $phar->startBuffering(); foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($filePath)) as $file){ - $path = ltrim(str_replace(array("\\", $filePath), array("/", ""), $file), "/"); + $path = ltrim(str_replace(["\\", $filePath], ["/", ""], $file), "/"); if($path{0} === "." or strpos($path, "/.") !== false){ continue; } $phar->addFile($file, $path); + $sender->sendMessage("[DevTools] Adding $path"); } $phar->compressFiles(\Phar::GZ); @@ -193,7 +192,7 @@ private function makePluginCommand(CommandSender $sender, Command $command, $lab } private function makeServerCommand(CommandSender $sender, Command $command, $label, array $args){ - $server = Server::getInstance(); + $server = $sender->getServer(); $pharPath = $this->getDataFolder() . DIRECTORY_SEPARATOR . $server->getName()."_".$server->getPocketMineVersion().".phar"; if(file_exists($pharPath)){ $sender->sendMessage("Phar file already exists, overwriting..."); @@ -215,16 +214,16 @@ private function makeServerCommand(CommandSender $sender, Command $command, $lab $filePath = substr(\pocketmine\PATH, 0, 7) === "phar://" ? \pocketmine\PATH : realpath(\pocketmine\PATH) . "/"; $filePath = rtrim(str_replace("\\", "/", $filePath), "/") . "/"; foreach(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($filePath . "src")) as $file){ - $path = ltrim(str_replace(array("\\", $filePath), array("/", ""), $file), "/"); + $path = ltrim(str_replace(["\\", $filePath], ["/", ""], $file), "/"); if($path{0} === "." or strpos($path, "/.") !== false or substr($path, 0, 4) !== "src/"){ continue; } $phar->addFile($file, $path); + $sender->sendMessage("[DevTools] Adding $path"); } - $phar->compressFiles(\Phar::GZ); $phar->stopBuffering(); - $sender->sendMessage("PocketMine-MP Phar file has been created on ".$pharPath); + $sender->sendMessage($server->getName() . " " . $server->getPocketMineVersion() . " Phar file has been created on ".$pharPath); return true; } diff --git a/src/DevTools/commands/DevToolsCommand.php b/src/DevTools/commands/DevToolsCommand.php index fab22d8..391b0a4 100644 --- a/src/DevTools/commands/DevToolsCommand.php +++ b/src/DevTools/commands/DevToolsCommand.php @@ -2,7 +2,7 @@ /* * DevTools plugin for PocketMine-MP - * Copyright (C) 2014 PocketMine Team + * Copyright (C) 2014 PocketMine Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by diff --git a/src/DevTools/commands/ExtractPluginCommand.php b/src/DevTools/commands/ExtractPluginCommand.php index 1b4756e..3474dfb 100644 --- a/src/DevTools/commands/ExtractPluginCommand.php +++ b/src/DevTools/commands/ExtractPluginCommand.php @@ -2,7 +2,7 @@ /* * DevTools plugin for PocketMine-MP - * Copyright (C) 2014 PocketMine Team + * Copyright (C) 2014 PocketMine Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by diff --git a/src/FolderPluginLoader/FolderPluginLoader.php b/src/FolderPluginLoader/FolderPluginLoader.php index 8b81e49..e999721 100644 --- a/src/FolderPluginLoader/FolderPluginLoader.php +++ b/src/FolderPluginLoader/FolderPluginLoader.php @@ -2,7 +2,7 @@ /* * DevTools plugin for PocketMine-MP - * Copyright (C) 2014 PocketMine Team + * Copyright (C) 2014 PocketMine Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by diff --git a/src/FolderPluginLoader/Main.php b/src/FolderPluginLoader/Main.php index 35640f6..cddb03b 100644 --- a/src/FolderPluginLoader/Main.php +++ b/src/FolderPluginLoader/Main.php @@ -28,7 +28,7 @@ public function onLoad(){ public function onEnable(){ $this->getServer()->getPluginManager()->registerInterface("FolderPluginLoader\\FolderPluginLoader"); - $this->getServer()->getPluginManager()->loadPlugins($this->getServer()->getPluginPath(), array("FolderPluginLoader\\FolderPluginLoader")); + $this->getServer()->getPluginManager()->loadPlugins($this->getServer()->getPluginPath(), ["FolderPluginLoader\\FolderPluginLoader"]); $this->getServer()->enablePlugins(PluginLoadOrder::STARTUP); } }