22declare(strict_types=1);
24namespace pocketmine\command\defaults;
39 public function __construct(){
42 KnownTranslationFactory::pocketmine_command_spawnpoint_description(),
43 KnownTranslationFactory::commands_spawnpoint_usage()
46 DefaultPermissionNames::COMMAND_SPAWNPOINT_SELF,
47 DefaultPermissionNames::COMMAND_SPAWNPOINT_OTHER
52 $target = $this->fetchPermittedPlayerTarget($sender, $args[0] ??
null, DefaultPermissionNames::COMMAND_SPAWNPOINT_SELF, DefaultPermissionNames::COMMAND_SPAWNPOINT_OTHER);
57 if(count($args) === 4){
58 $world = $target->getWorld();
59 $pos = $sender instanceof
Player ? $sender->getPosition() : $world->getSpawnLocation();
60 $x = $this->getRelativeDouble($pos->x, $sender, $args[1]);
61 $y = $this->getRelativeDouble($pos->y, $sender, $args[2], World::Y_MIN, World::Y_MAX);
62 $z = $this->getRelativeDouble($pos->z, $sender, $args[3]);
63 $target->setSpawn(
new Position($x, $y, $z, $world));
65 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_spawnpoint_success($target->getName(), (
string) round($x, 2), (
string) round($y, 2), (
string) round($z, 2)));
68 }elseif(count($args) <= 1 && $sender instanceof
Player){
69 $cpos = $sender->getPosition();
71 $target->setSpawn($pos);
73 Command::broadcastCommandMessage($sender, KnownTranslationFactory::commands_spawnpoint_success($target->getName(), (
string) round($pos->x, 2), (
string) round($pos->y, 2), (
string) round($pos->z, 2)));
setPermissions(array $permissions)
execute(CommandSender $sender, string $commandLabel, array $args)
static fromObject(Vector3 $pos, ?World $world)