本文整理汇总了PHP中pocketmine\command\CommandSender::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::getID方法的具体用法?PHP CommandSender::getID怎么用?PHP CommandSender::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::getID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(CommandSender $issuer, $alias, array $args)
{
if ($issuer instanceof Player) {
if (isset($args[0])) {
if (($name = strtolower($args[0])) === "-all") {
if (!$issuer->hasPermission("lagfixer.show.all")) {
$issuer->sendMessage("You don't have permission to show all invisible players in once.");
return false;
}
foreach ($this->plugin->getServer()->getOnlinePlayers() as $player) {
if ($player->getID() !== $issuer->getID()) {
$player->spawnTo($issuer);
}
}
$issuer->sendMessage("All visible players have been sent to you.");
return true;
} else {
if (!$issuer->hasPermission("lagfixer.show.player")) {
$issuer->sendMessage("You don't have permission to show an invisible player.");
return false;
}
$player = $this->plugin->getServer()->getPlayer($args[0]);
if ($player instanceof Player and $player->getID() !== $issuer->getID()) {
$player->spawnTo($issuer);
return true;
}
}
}
$issuer->sendMessage("Wrong usage: Argument 1 must be a player name or part of it.");
$issuer->sendMessage("Usage: " . $this->getUsage());
return false;
}
$issuer->sendMessage("Please run this command in-game. You shouldn't see any graphical players here.");
return false;
}
示例2: onCommand
public function onCommand(CommandSender $p, Command $command, $label, array $args)
{
if (strtolower($command->getName()) == "blockl") {
$brek = $p->getID();
$pos = $p->getName();
if (!in_array($brek, $this->locations)) {
$this->locations[$pos] = $brek;
$p->sendMessage("BreakPosition On");
} else {
$fr = array_search($brek, $this->locations);
unset($this->locations[$fr]);
$p->sendMessage("BreakPosition Off");
}
}
}
示例3: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (isset($args[1])) {
if ($sender->hasPermission("disguiseme.other")) {
if (($p = $this->getServer()->getPlayer($args[1])) instanceof Player) {
if ($this->isDisguised($p->getID())) {
$this->destroyDisguise($p->getID());
$sender->sendMessage("Disguise closed for " . $p->getName());
$p->sendMessage("Your disguise has been closed.");
return true;
} else {
if (is_numeric($args[0])) {
$s = new DisguiseSession($p, $args[0]);
$this->e[$p->getID()] = $s;
$sender->sendMessage("Disguise activated for " . $p->getName());
$p->sendMessage("You now have a disguise.");
} elseif (($mob = $this->getMobStore()->getMobId($args[0])) !== false) {
$s = new DisguiseSession($p, $mob);
$this->e[$p->getID()] = $s;
$sender->sendMessage("Disguise activated for " . $p->getName());
$p->sendMessage("You now have a disguise.");
} else {
$sender->sendMessage("No mob found with that name.");
}
return true;
}
} else {
$sender->sendMessage("Player not found.");
return true;
}
} else {
$sender->sendMessage("You do not have permission to disguise others.");
return true;
}
} else {
if ($sender instanceof Player) {
if ($this->isDisguised($sender->getID())) {
$this->destroyDisguise($sender->getID());
$sender->sendMessage("Disguise closed.");
return true;
} else {
if (isset($args[0])) {
if (is_numeric($args[0])) {
$s = new DisguiseSession($sender, $args[0]);
$this->e[$sender->getID()] = $s;
$sender->sendMessage("Disguise activated.");
} elseif (($mob = $this->getMobStore()->getMobId($args[0])) !== false) {
$s = new DisguiseSession($sender, $mob);
$this->e[$sender->getID()] = $s;
$sender->sendMessage("Disguise activated.");
} else {
$sender->sendMessage("No mob found with that name.");
}
return true;
} else {
$sender->sendMessage("You need to specify a mob.");
return true;
}
}
} else {
$sender->sendMessage("You need to specify a player.");
return true;
}
}
}
示例4: onCommand
public function onCommand(CommandSender $issuer, Command $command, $label, array $args)
{
switch ($command->getName()) {
case "sign":
if ($issuer instanceof Player) {
$interval = 40;
if (isset($args[0])) {
$interval = floatval($args[0]) * 20;
}
$scroll = 2;
if (isset($args[1])) {
$scroll = intval($args[1]);
}
$this->signTouchSessions[$issuer->getID()] = ["id" => self::SESSION_SIGN_SIGN, "interval" => $interval, "scroll" => $scroll];
$issuer->sendMessage("Please tap on a sign to sign it.");
return true;
}
$issuer->sendMessage("Please run this command in-game.");
return true;
}
return false;
}
示例5: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $alias, array $args)
{
if (!isset($args[0])) {
return false;
}
$k = $sender instanceof Player ? $sender->getID() : get_class($sender);
switch ($subcmd = array_shift($args)) {
case "stop":
if (!isset($this->stack[$k])) {
$sender->sendMessage("You don't have a recording macro to stop!");
break;
}
if (!isset($args[0])) {
$sender->sendMessage("Usage: /macro stop <name>");
$sender->sendMessage("Don't worry, this command will not be recorded.");
break;
}
if (strtolower($name = array_shift($args)) === "ng") {
$sender->sendMessage("This NG macro has been discarded.");
// continue to run: unset stack
} else {
if ($this->getMacro($name) !== false) {
$sender->sendMessage("There is already a macro called \"{$name}\"!");
$sender->sendMessage("Don't worry, this command will not be recorded.");
break;
}
$success = $this->saveMacro($name, $this->stack[$k]);
if (!$success) {
$sender->sendMessage("Unable to create file. Perhaps \"{$name}\" is not a valid filename?");
$sender->sendMessage("Don't worry, this command will not be recorded.");
break;
}
// continue to run: unset stack
}
if (isset($this->stack[$id = $k])) {
// copied xD
unset($this->stack[$id]);
// avoid bugs if the entity ID gets reused
}
if (isset($this->paused[$id])) {
unset($this->stack[$id]);
}
$sender->sendMessage("You have successfully saved macro {$name}.");
break;
case "start":
if (!$sender->hasPermission("simplemacros.record")) {
$sender->sendMessage("You don't have permission to record a macro.");
return true;
}
if (isset($this->stack[$k])) {
$sender->sendMessage("You have already started recording a macro!");
return true;
}
$this->stack[$k] = "";
$sender->sendMessage("You are now recording a macro.");
break;
case "pause":
if (!isset($this->stack[$k])) {
$sender->sendMessage("You are not recording a macro!");
return true;
}
$this->paused[$k] = true;
$sender->sendMessage("Your macro is now paused.");
$sender->sendMessage("Don't worry, this command will not be recorded.");
break;
case "resume":
if (!isset($this->paused[$k]) or $this->paused[$k] === false) {
$sender->sendMessage("You do not have a paused recording macro!");
$sender->sendMessage("Don't worry, this command will not be recorded.");
return true;
}
$this->paused[$k] = false;
$sender->sendMessage("You have now resumed your macro.");
break;
case "sudo":
if (!$sender->hasPermission("simplemacros.sudo")) {
$sender->sendMessage("You don't have permision to sudo others with a macro.");
return true;
}
if (!isset($args[1])) {
$sender->sendMessage("Usage: /macro sudo <macro name> <player name> [-op]");
return true;
}
$macro = $this->getMacro($name = array_shift($args));
if ($macro === false) {
$sender->sendMessage("{$macro} doesn't exist!");
return true;
}
if (!($p = $this->getServer()->getPlayer($args[1])) instanceof Player) {
$sender->sendMessage("Player {$args['1']} not found!");
return true;
}
if (isset($args[2]) and $args[2] === "-op" and !$sender->hasPermission("simplemacros.opsudo")) {
$sender->sendMessage("You do not have permission to op-sudo a player with a macro!");
}
foreach ($macro as $rline) {
$line = trim($rline);
if (isset($args[2]) and $args[2] === "-op") {
if (($rcmd = $this->getServer()->getCommandMap()->getCommand(strstr($line, " ", true))) instanceof Command) {
if (!$cmd->testPermissionSilent($p) and $cmd->testPermissionSilent($sender)) {
//.........这里部分代码省略.........