mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Added /setworldspawn
This commit is contained in:
parent
1dc3d42b78
commit
e9aba34e6b
@ -44,6 +44,7 @@ use pocketmine\command\defaults\SaveOffCommand;
|
||||
use pocketmine\command\defaults\SaveOnCommand;
|
||||
use pocketmine\command\defaults\SayCommand;
|
||||
use pocketmine\command\defaults\SeedCommand;
|
||||
use pocketmine\command\defaults\SetWorldSpawnCommand;
|
||||
use pocketmine\command\defaults\SpawnpointCommand;
|
||||
use pocketmine\command\defaults\StatusCommand;
|
||||
use pocketmine\command\defaults\StopCommand;
|
||||
@ -97,6 +98,7 @@ class SimpleCommandMap implements CommandMap{
|
||||
$this->register("pocketmine", new GamemodeCommand("gamemode"));
|
||||
$this->register("pocketmine", new KillCommand("kill"));
|
||||
$this->register("pocketmine", new SpawnpointCommand("spawnpoint"));
|
||||
$this->register("pocketmine", new SetWorldSpawnCommand("setworldspawn"));
|
||||
$this->register("pocketmine", new TeleportCommand("tp"));
|
||||
$this->register("pocketmine", new ReloadCommand("reload"));
|
||||
|
||||
|
70
src/pocketmine/command/defaults/SetWorldSpawnCommand.php
Normal file
70
src/pocketmine/command/defaults/SetWorldSpawnCommand.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\command\defaults;
|
||||
|
||||
use pocketmine\command\Command;
|
||||
use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\ConsoleCommandSender;
|
||||
use pocketmine\level\Position;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class SetWorldSpawnCommand extends VanillaCommand{
|
||||
|
||||
public function __construct($name){
|
||||
parent::__construct(
|
||||
$name,
|
||||
"Sets a worlds's spawn point. If no coordinates are specified, the player's coordinates will be used.",
|
||||
"/setworldspawn OR /setworldspawn <x> <y> <z>"
|
||||
);
|
||||
$this->setPermission("pocketmine.command.setworldspawn");
|
||||
}
|
||||
|
||||
public function execute(CommandSender $sender, $currentAlias, array $args){
|
||||
if(!$this->testPermission($sender)){
|
||||
return true;
|
||||
}
|
||||
|
||||
if(count($args) === 0){
|
||||
if($sender instanceof Player){
|
||||
$level = $sender->getLevel();
|
||||
$pos = $sender->round();
|
||||
}else{
|
||||
$sender->sendMessage(TextFormat::RED . "You can only perform this command as a player");
|
||||
return true;
|
||||
}
|
||||
}elseif(count($args) === 3){
|
||||
$level = Server::getInstance()->getDefaultLevel();
|
||||
$pos = new Vector3($this->getInteger($sender, $args[0]), $this->getInteger($sender, $args[1]), $this->getInteger($sender, $args[2]));
|
||||
}else{
|
||||
$sender->sendMessage(TextFormat::RED . "Usage: ".$this->usageMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
$level->setSpawn($pos);
|
||||
|
||||
Command::broadcastCommandMessage($sender, "Set world ".$level->getName()."'s spawnpoint to ".$pos->x.", ".$pos->y.", ".$pos->z);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -107,6 +107,8 @@ abstract class DefaultPermissions{
|
||||
self::registerPermission(new Permission(self::ROOT . ".command.defaultgamemode", "Allows the user to change the default gamemode", Permission::DEFAULT_OP), $commands);
|
||||
self::registerPermission(new Permission(self::ROOT . ".command.seed", "Allows the user to view the seed of the world", Permission::DEFAULT_OP), $commands);
|
||||
self::registerPermission(new Permission(self::ROOT . ".command.status", "Allows the user to view the server performance", Permission::DEFAULT_OP), $commands);
|
||||
self::registerPermission(new Permission(self::ROOT . ".command.spawnpoint", "Allows the user to change player's spawnpoint", Permission::DEFAULT_OP), $commands);
|
||||
self::registerPermission(new Permission(self::ROOT . ".command.setworldspawn", "Allows the user to change the world spawn", Permission::DEFAULT_OP), $commands);
|
||||
|
||||
$commands->recalculatePermissibles();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user