Added /time start and /time stop

This commit is contained in:
Shoghi Cervantes 2014-11-01 17:45:11 +01:00
parent 4d97827d44
commit 8a87280566
2 changed files with 39 additions and 2 deletions

View File

@ -32,12 +32,47 @@ class TimeCommand extends VanillaCommand{
parent::__construct(
$name,
"Changes the time on each world",
"/time set <value>\n/time add <value>"
"/time set <value>\n/time add <value>\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);

View File

@ -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);