diff --git a/src/build/installer.sh b/src/build/installer.sh index c331ae7d4..74e7e5cd5 100644 --- a/src/build/installer.sh +++ b/src/build/installer.sh @@ -70,7 +70,7 @@ rm -f start.bat echo "[2/3] Downloading PocketMine-MP $PMMP_VERSION..." set +e download_file "https://github.com/PocketMine/PocketMine-MP/releases/download/$PMMP_VERSION/PocketMine-MP.phar" > PocketMine-MP.phar -if ! [ -s "PocketMine-MP.phar" ]; then +if ! [ -s "PocketMine-MP.phar" ] || [ "$(head -n 1 PocketMine-MP.phar)" == '' ]; then rm "PocketMine-MP.phar" > /dev/null download_file "https://github.com/PocketMine/PocketMine-MP/archive/$PMMP_VERSION.tar.gz" | tar -zx > /dev/null COMPILE_SCRIPT="./src/build/compile.sh" diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 566133b08..382d62da9 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -890,7 +890,7 @@ class Server{ return false; } - if($generator !== false and class_exists($generator) and is_subclass_of($generator, "pocketmine\\level\\generator\\Generator")){ + if($generator !== null and class_exists($generator) and is_subclass_of($generator, "pocketmine\\level\\generator\\Generator")){ $generator = new $generator($options); }else{ if(strtoupper($this->getLevelType()) == "FLAT"){ @@ -1568,7 +1568,7 @@ class Server{ return; } ini_set("memory_limit", "-1"); //Fix error dump not dumped on memory problems - console("[SEVERE] An unrecovereable has ocurred and the server has crashed. Creating an error dump"); + console("[SEVERE] An unrecoverable has occurred and the server has crashed. Creating an error dump"); $dump = "```\r\n# PocketMine-MP Error Dump " . date("D M j H:i:s T Y") . "\r\n"; $er = error_get_last(); $errorConversion = array( @@ -1842,4 +1842,4 @@ class Server{ return false; } -} \ No newline at end of file +} diff --git a/src/pocketmine/command/Command.php b/src/pocketmine/command/Command.php index e04959bcb..d2b0ae821 100644 --- a/src/pocketmine/command/Command.php +++ b/src/pocketmine/command/Command.php @@ -301,4 +301,11 @@ abstract class Command{ } } } -} \ No newline at end of file + + /** + * @return string + */ + public function __toString(){ + return $this->name; + } +} diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index 15018b3dc..30267ee77 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -53,6 +53,7 @@ use pocketmine\command\defaults\TellCommand; use pocketmine\command\defaults\VanillaCommand; use pocketmine\command\defaults\VersionCommand; use pocketmine\command\defaults\WhitelistCommand; +use pocketmine\command\defaults\TimeCommand; use pocketmine\Server; class SimpleCommandMap implements CommandMap{ @@ -101,6 +102,7 @@ class SimpleCommandMap implements CommandMap{ $this->register("pocketmine", new SetWorldSpawnCommand("setworldspawn")); $this->register("pocketmine", new TeleportCommand("tp")); $this->register("pocketmine", new ReloadCommand("reload")); + $this->register("pocketmine", new TimeCommand("time")); if($this->server->getConfigBoolean("debug.commands", false) === true){ $this->register("pocketmine", new StatusCommand("status")); diff --git a/src/pocketmine/command/defaults/TimeCommand.php b/src/pocketmine/command/defaults/TimeCommand.php new file mode 100644 index 000000000..0aac0c5dd --- /dev/null +++ b/src/pocketmine/command/defaults/TimeCommand.php @@ -0,0 +1,67 @@ +\n/time add " + ); + $this->setPermission("pocketmine.command.time.add;pocketmine.command.set;"); + } + + public function execute(CommandSender $sender, $label, array $args){ + if (count($args) < 2) { + $sender->sendMessage(TextFormat::RED."Incorrect usage. Correct usage:\n".$this->getUsage()); + return false; + } + + switch(strtolower($args[0])){ + case "set": + if(!$sender->hasPermission("pocketmine.command.time.add")){ + $sender->sendMessage(TextFormat::RED."You don't have permission to set the time"); + return true; + } + + if($args[1] === "day"){ + $value = 0; + }elseif($args[1] === "night"){ + $value = 12500; + }else{ + $value = $this->getInteger($sender, $args[1], 0); + } + + foreach(Server::getInstance()->getLevels() as $level){ + $level->setTime($value); + } + Command::broadcastCommandMessage($sender, "Set time to ".$value); + + return true; + case "add": + if (!$sender->hasPermission("pocketmine.command.time.add")){ + $sender->sendMessage(TextFormat::RED."You don't have permission to set the time"); + return true; + } + + $value = $this->getInteger($sender, $args[1], 0); + + foreach(Server::getInstance()->getLevels() as $level){ + $level->setTime($level->getTime() + $value); + } + + Command::broadcastCommandMessage($sender, "Added ".$value." to time"); + + return true; + default: + $sender->sendMessage("Unknown method. Usage: ".$this->getUsage()); + } + } +} \ No newline at end of file diff --git a/src/pocketmine/permission/PermissibleBase.php b/src/pocketmine/permission/PermissibleBase.php index 781f9fbc3..0ee752042 100644 --- a/src/pocketmine/permission/PermissibleBase.php +++ b/src/pocketmine/permission/PermissibleBase.php @@ -69,7 +69,7 @@ class PermissibleBase implements Permissible{ */ public function setOp($value){ if($this->opable === null){ - trigger_error("Cannot change ip value as no ServerOperator is set", E_USER_WARNING); + trigger_error("Cannot change op value as no ServerOperator is set", E_USER_WARNING); return; }else{ @@ -217,4 +217,4 @@ class PermissibleBase implements Permissible{ public function getEffectivePermissions(){ return $this->permissions; } -} \ No newline at end of file +} diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 3db5549ea..d3b8d4a24 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -36,9 +36,6 @@ use pocketmine\Server; */ class PluginManager{ - /** @var PluginManager */ - private static $instance = null; - /** @var Server */ private $server; @@ -85,13 +82,6 @@ class PluginManager{ */ protected $fileAssociations = array(); - /** - * @return PluginManager - */ - public static function getInstance(){ - return self::$instance; - } - /** * @param Server $server * @param SimpleCommandMap $commandMap @@ -692,4 +682,4 @@ class PluginManager{ return $event::$handlerList; } -} \ No newline at end of file +} diff --git a/src/pocketmine/scheduler/CallbackTask.php b/src/pocketmine/scheduler/CallbackTask.php index 1cfc65804..d8e2771a6 100644 --- a/src/pocketmine/scheduler/CallbackTask.php +++ b/src/pocketmine/scheduler/CallbackTask.php @@ -22,7 +22,7 @@ namespace pocketmine\scheduler; /** - * Allows the creation if simple callbacks with extra data + * Allows the creation of simple callbacks with extra data * The last parameter in the callback will be this object * * If you want to do a task in a Plugin, consider extending PluginTask to your needs