当前位置: 首页>>代码示例>>PHP>>正文


PHP CommandSender::setHealth方法代码示例

本文整理汇总了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;
             }
         }
     }
 }
开发者ID:0-DevMatthew-0,项目名称:RandomCommandsPlugin,代码行数:25,代码来源:heal.php

示例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;
     }
 }
开发者ID:Skull3x,项目名称:RussianRoulette,代码行数:27,代码来源:Main.php

示例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;
     }
 }
开发者ID:NameNoOne100,项目名称:AFKsource,代码行数:22,代码来源:Main.php

示例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;
         }
     }
 }
开发者ID:0-DevMatthew-0,项目名称:ApplicationPlugin,代码行数:79,代码来源:main.php


注:本文中的pocketmine\command\CommandSender::setHealth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。