本文整理汇总了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;
}
}