本文整理汇总了PHP中pocketmine\command\CommandSender::setHealth方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::setHealth方法的具体用法?PHP CommandSender::setHealth怎么用?PHP CommandSender::setHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::setHealth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
$name = $sender->getName();
if (strtolower($command->getName()) == 'heal') {
if (count($args) > 0) {
$player = $args[0];
if ($this->getServer()->getPlayer($player)) {
$player = $this->getServer()->getPlayer($player);
$player->setHealth(20);
$sender->sendMessage(TextFormat::BLUE . "[Server] Player " . $player->getName() . " has been healed!");
$player->sendMessage(TextFormat::RED . "You have been healed!");
return;
} else {
$sender->sendMessage(TextFormat::BLUE . "[Server] {$player} isn't online at the moment. Please try again when he returns!");
return;
}
} else {
$sender->setHealth(20);
$sender->sendMessage(TextFormat::RED . "You have been healed!");
return;
}
}
}
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) == "bam") {
if ($sender instanceof Player) {
if (!($sender->hasPermission("bambam") || $sender->hasPermission("bambam.command") || $sender->hasPermission("bambam.command.bam"))) {
return false;
}
$chambers = $this->getConfig()->get("chambers");
if ($chambers < 2) {
$sender->sendMessage(TextFormat::RED . "You don't have enough chambers!");
return true;
}
if (mt_rand(1, $chambers) == 1) {
$sender->setHealth(0);
$sender->sendMessage(TextFormat::RED . "Unlucky.");
} else {
$sender->sendMessage(TextFormat::GREEN . "You survived.");
foreach ($this->getConfig()->get("commands") as $command) {
$this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $sender->getName(), $command));
}
}
} else {
$sender->sendMessage(TextFormat::RED . "You can only play in-game!");
}
return true;
}
}
示例3: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
$name = $sender->getName();
if (strtolower($command->getName()) == "afk") {
if (count($args) < 1) {
$Phealth = getHealth();
$sender->sendMessage(Color::GREEN . "[AFK plugin] You are now AFK!");
$sender->setHealth(20);
$sender->getEffect(10);
$this->god = true;
return;
} else {
$sender->sendMessage(Color::GREEN . "[AFK plugin] This command has no arguments!");
return;
}
}
} else {
$sender->sendMessage(Color::RED . "That command can only be run in console!");
return;
}
}
示例4: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
$name = $sender->getName();
if (strtolower($command->getName()) == 'heal') {
if (count($args) > 0) {
$player = $args[0];
if ($this->getServer()->getPlayer($player)) {
$player = $this->getServer()->getPlayer($player);
$player->setHealth(20);
$sender->sendMessage(Color::BLUE . "[Server] Player " . $player->getName() . " has been healed!");
$player->sendMessage(Color::RED . "You have been healed!");
return;
} else {
$sender->sendMessage(Color::BLUE . "[Server] {$player} isn't online at the moment. Please try again when he returns!");
return;
}
} else {
$sender->setHealth(20);
$sender->sendMessage(Color::RED . "You have been healed!");
return;
}
}
if ($sender instanceof Player) {
$name = $sender->getName();
switch (strtolower($command->getName())) {
case 'main':
$sender->sendMessage(Color::RED . "[Bolts] Hello! {$name} you may know me as Bolts! I would like to be a developer because while support may be fun, its not something that suits me much. Thats where coding comes in.");
return;
break;
case 'servversion':
$version = $this->getServer()->getVersion();
$sender->sendMessage(Color::BLUE . "[Server] The server version is [{$version}]");
return;
break;
case 'experience':
$sender->sendMessage(Color::RED . "[Bolts] The coding languages I have learned are python, getting into php, getting into angularjs, basic html and one day Java.");
return;
break;
case 'information':
$sender->sendMessage(Color::BLUE . "[Bolts] You should already know this. After all I already work for you :)");
return;
break;
case 'whyiamapplying':
$sender->sendMessage(Color::RED . "[Bolts] There are a plethora of reasons why. If you want me to go through them ask me :)");
return;
break;
case 'promote':
if (count($args) > 0) {
switch (count($args)) {
case 1:
$sub = $args[0];
$sender->sendMessage(Color::BLUE . "[Server] You have promoted {$sub}!");
return;
break;
case 2:
$sub = $args[0];
$sub2 = $args[1];
$sender->sendMessage(Color::RED . "[Server] You have promoted {$sub} and {$sub2}!");
return;
break;
case 3:
$sub = $args[0];
$sub2 = $args[1];
$sub3 = $args[2];
$sender->sendMessage(Color::BLUE . "[Server] You have promoted {$sub}, {$sub2} and {$sub3}!");
return;
break;
}
} else {
$sender->sendMessage(Color::RED . '[Server] You have been promoted!');
return;
}
}
$sender->sendMessage(Color::BLUE . "[Bolts] You must run this command in-game!");
return;
}
}
}