本文整理匯總了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;
}
}
示例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;
}
}