本文整理匯總了PHP中pocketmine\command\CommandSender::setAllowFlight方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommandSender::setAllowFlight方法的具體用法?PHP CommandSender::setAllowFlight怎麽用?PHP CommandSender::setAllowFlight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::setAllowFlight方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (strtolower($cmd->getName()) === "fly") {
if (empty($args)) {
if (!$sender->hasPermission("flycommand.me")) {
$sender->sendMessage(TextFormat::RED . "You do not have permission to use this command");
return true;
} else {
if (!$sender instanceof Player) {
$sender->sendMessage(TextFormat::RED . "Command only allowed in-game");
return true;
}
if ($sender->getAllowFlight()) {
$sender->setAllowFlight(false);
$sender->sendMessage(TextFormat::GREEN . "Flight mode disabled");
return true;
} else {
$sender->setAllowFlight(true);
$sender->sendMessage(TextFormat::GREEN . "Flight mode enabled");
return true;
}
}
} else {
if (count($args === 1)) {
$player = $this->getServer()->getPlayer($args[0]);
if (!$sender->hasPermission("flycommand.others")) {
$sender->sendMessage(TextFormat::RED . "You do not have permission to use this command");
return true;
} else {
if ($player === null) {
$sender->sendMessage(TextFormat::RED . "Player not online");
return true;
}
if ($player->getAllowFlight()) {
$player->setAllowFlight(false);
$player->sendMessage(TextFormat::GREEN . "Flight mode disabled");
$sender->sendMessage(TextFormat::GREEN . "Flight mode disabled for player: " . TextFormat::WHITE . $player->getName());
return true;
} else {
$player->setAllowFlight(true);
$player->sendMessage(TextFormat::GREEN . "Flight mode enabled");
$sender->sendMessage(TextFormat::GREEN . "Flight mode enabled for player: " . TextFormat::WHITE . $player->getName());
return true;
}
}
}
}
}
return false;
}