diff --git a/src/pocketmine/command/defaults/TimeCommand.php b/src/pocketmine/command/defaults/TimeCommand.php index 346bfb4b8..ca7d90300 100644 --- a/src/pocketmine/command/defaults/TimeCommand.php +++ b/src/pocketmine/command/defaults/TimeCommand.php @@ -32,12 +32,47 @@ class TimeCommand extends VanillaCommand{ parent::__construct( $name, "Changes the time on each world", - "/time set \n/time add " + "/time set \n/time add \n/time start|stop" ); - $this->setPermission("pocketmine.command.time.add;pocketmine.command.time.set"); + $this->setPermission("pocketmine.command.time.add;pocketmine.command.time.set;pocketmine.command.time.start;pocketmine.command.time.stop"); } public function execute(CommandSender $sender, $currentAlias, array $args){ + if(count($args) < 1){ + $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage); + + return false; + } + + if($args[0] === "start"){ + if(!$sender->hasPermission("pocketmine.command.time.start")){ + $sender->sendMessage(TextFormat::RED . "You don't have permission to restart the time"); + + return true; + } + foreach($sender->getServer()->getLevels() as $level){ + $level->checkTime(); + $level->startTime(); + $level->checkTime(); + } + Command::broadcastCommandMessage($sender, "Restarted the time"); + return true; + }elseif($args[0] === "stop"){ + if(!$sender->hasPermission("pocketmine.command.time.stop")){ + $sender->sendMessage(TextFormat::RED . "You don't have permission to stop the time"); + + return true; + } + foreach($sender->getServer()->getLevels() as $level){ + $level->checkTime(); + $level->stopTime(); + $level->checkTime(); + } + Command::broadcastCommandMessage($sender, "Stopped the time"); + return true; + } + + if(count($args) < 2){ $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage); diff --git a/src/pocketmine/permission/DefaultPermissions.php b/src/pocketmine/permission/DefaultPermissions.php index 45fda6efe..c2051e631 100644 --- a/src/pocketmine/permission/DefaultPermissions.php +++ b/src/pocketmine/permission/DefaultPermissions.php @@ -88,6 +88,8 @@ abstract class DefaultPermissions{ $time = self::registerPermission(new Permission(self::ROOT . ".command.time", "Allows the user to alter the time", Permission::DEFAULT_OP), $commands); self::registerPermission(new Permission(self::ROOT . ".command.time.add", "Allows the user to fast-forward time"), $time); self::registerPermission(new Permission(self::ROOT . ".command.time.set", "Allows the user to change the time"), $time); + self::registerPermission(new Permission(self::ROOT . ".command.time.start", "Allows the user to restart the time"), $time); + self::registerPermission(new Permission(self::ROOT . ".command.time.stop", "Allows the user to stop the time"), $time); $time->recalculatePermissibles(); self::registerPermission(new Permission(self::ROOT . ".command.kill", "Allows the user to commit suicide", Permission::DEFAULT_TRUE), $commands);