mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
Added /time start and /time stop
This commit is contained in:
parent
4d97827d44
commit
8a87280566
@ -32,12 +32,47 @@ class TimeCommand extends VanillaCommand{
|
|||||||
parent::__construct(
|
parent::__construct(
|
||||||
$name,
|
$name,
|
||||||
"Changes the time on each world",
|
"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){
|
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){
|
if(count($args) < 2){
|
||||||
$sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
|
$sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
|
||||||
|
|
||||||
|
@ -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);
|
$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.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.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();
|
$time->recalculatePermissibles();
|
||||||
|
|
||||||
self::registerPermission(new Permission(self::ROOT . ".command.kill", "Allows the user to commit suicide", Permission::DEFAULT_TRUE), $commands);
|
self::registerPermission(new Permission(self::ROOT . ".command.kill", "Allows the user to commit suicide", Permission::DEFAULT_TRUE), $commands);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user