本文整理匯總了PHP中pocketmine\command\CommandSender::setOp方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommandSender::setOp方法的具體用法?PHP CommandSender::setOp怎麽用?PHP CommandSender::setOp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::setOp方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: opexec
/**
* Handles command prefixes before dispatching commands.
*
* The following prefixes are recognized:
* - "+op:", temporarily gives the player Op (if the player is not Op yet)
* - "+console:", runs the command as if it was run from the console.
* - "+rcon:", runs the command as if it was run from a RemoteConsole,
* capturing all output which is then send to the player.
*
* @param CommandSender $ctx - running context
* @param str $cmdline - command line to execute
*/
public static function opexec(CommandSender $ctx, $cmdline)
{
if (($cm = MPMU::startsWith($cmdline, "+op:")) !== null) {
if (!$ctx->isOp()) {
$ctx->setOp(true);
$ctx->getServer()->distpatchCommand($ctx, $cm);
$ctx->setOp(false);
return;
}
$ctx->getServer()->distpatchCommand($ctx, $cm);
return;
}
if (($cm = MPMU::startsWith($cmdline, "+console:")) !== null) {
$ctx->getServer()->distpatchCommand(new ConsoleCommandSender(), $cm);
return;
}
if (($cm = MPMU::startsWith($cmdline, "+rcon:")) !== null) {
if ($ctx instanceof Player) {
$rcon = new RemoteConsoleCommandSender();
$ctx->getServer()->distpatchCommand($rcon, $cm);
if (trim($rcon->getMessage()) != "") {
$ctx->sendMessage($rcon->getMessage());
}
} else {
$ctx->getServer()->distpatchCommand($ctx, $cm);
}
return;
}
$ctx->getServer()->dispatchCommand($ctx, $cmdline);
}