當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CommandSender::setFood方法代碼示例

本文整理匯總了PHP中pocketmine\command\CommandSender::setFood方法的典型用法代碼示例。如果您正苦於以下問題:PHP CommandSender::setFood方法的具體用法?PHP CommandSender::setFood怎麽用?PHP CommandSender::setFood使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\command\CommandSender的用法示例。


在下文中一共展示了CommandSender::setFood方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 public function execute(cmd\CommandSender $sender, $label, array $args)
 {
     if ($sender instanceof Player) {
         if (count($args) != 0) {
             if ($sender->hasPermission("feedme.other")) {
                 $name = $args[0];
                 $player = $this->plugin->getServer()->getPlayer($name);
                 if ($player instanceof Player) {
                     // Send some pointless messeges
                     $sender->sendMessage(TextFormat::BLUE . "Yo mama fed " . $name . " face!");
                     $player->sendMessage(TextFormat::BLUE . $sender->getName() . " mama fed ur face!");
                     // set food to 20
                     $player->setFood(20);
                     return true;
                 } else {
                     $sender->sendMessage(TextFormat::BLUE . "Player ain't online!");
                     return true;
                 }
             } else {
                 $sender->sendMessage(TextFormat::DARK_RED . "Ain't nobody got that permissions!");
                 return true;
             }
         } else {
             // If args is missing set your own food to 20
             $sender->sendMessage(TextFormat::BLUE . "Yo mama fed ur face!");
             $sender->setFood(20);
             return true;
         }
     } else {
         $sender->sendMessage(TextFormat::DARK_RED . "Nah not gonna feed that console");
         return true;
     }
 }
開發者ID:TomasOlsson,項目名稱:YoMomaFeed,代碼行數:33,代碼來源:feed.php

示例2: execute

 public function execute(cmd\CommandSender $sender, $label, array $args)
 {
     if ($sender instanceof Player) {
         if (count($args) != 0) {
             if ($sender->hasPermission("feedme.other")) {
                 $name = $args[0];
                 $player = $this->plugin->getServer()->getPlayer($name);
                 if ($player instanceof Player) {
                     // Send some pointless messeges
                     $sender->sendMessage(TextFormat::BLUE . "Der Spieler " . $name . " wurde gefuettert!");
                     $player->sendMessage(TextFormat::BLUE . $sender->getName() . " hat dich gefuettert!");
                     // set food to 20
                     $player->setFood(20);
                     return true;
                 } else {
                     $sender->sendMessage(TextFormat::BLUE . "Spieler ist nicht online!");
                     return true;
                 }
             } else {
                 $sender->sendMessage(TextFormat::DARK_RED . "Du hast nicht die Berechtigung zum fuettern!");
                 return true;
             }
         } else {
             // If args is missing set your own food to 20
             $sender->sendMessage(TextFormat::BLUE . "Du wurdest gefuettert!");
             $sender->setFood(20);
             return true;
         }
     } else {
         $sender->sendMessage(TextFormat::DARK_RED . "Du kannst die Konsole nicht füttern!");
         return true;
     }
 }
開發者ID:HimbeersaftLP,項目名稱:AntiHunger-YoMomaFeed-in-German,代碼行數:33,代碼來源:feed.php


注:本文中的pocketmine\command\CommandSender::setFood方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。