本文整理汇总了PHP中pocketmine\level\Location::fromObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::fromObject方法的具体用法?PHP Location::fromObject怎么用?PHP Location::fromObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\level\Location
的用法示例。
在下文中一共展示了Location::fromObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @param CommandSender $sender
* @param string $alias
* @param array $args
* @return bool
*/
public function execute(CommandSender $sender, $alias, array $args)
{
if (!$this->testPermission($sender)) {
return false;
}
if (!isset($args[0]) && !$sender instanceof Player || count($args) > 1) {
$this->sendUsage($sender, $alias);
return false;
}
$player = $sender;
if (isset($args[0])) {
if (!$sender->hasPermission("essentials.spawn.other")) {
$sender->sendMessage(TextFormat::RED . "[Error] You can't teleport other players to spawn");
return false;
} elseif (!($player = $this->getAPI()->getPlayer($args[0]))) {
$sender->sendMessage(TextFormat::RED . "[Error] Player not found");
return false;
}
}
$player->teleport(Location::fromObject($this->getAPI()->getServer()->getDefaultLevel()->getSpawnLocation(), $this->getAPI()->getServer()->getDefaultLevel()));
$player->sendMessage(TextFormat::GREEN . "Teleporting...");
return true;
}
示例2: setWarp
/**
* Create a warp or override its position
*
* @param string $warp
* @param Position $pos
* @param int $yaw
* @param int $pitch
* @return bool
*/
public function setWarp($warp, Position $pos, $yaw = 0, $pitch = 0)
{
if (!$this->validateName($warp, false)) {
return false;
}
$this->warps[$warp] = $pos instanceof BaseLocation ? $pos : BaseLocation::fromPosition($warp, $pos instanceof Location ? $pos : Location::fromObject($pos, $pos->getLevel(), $yaw, $pitch));
return true;
}