本文整理汇总了PHP中pocketmine\event\player\PlayerItemConsumeEvent::getPlayer方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerItemConsumeEvent::getPlayer方法的具体用法?PHP PlayerItemConsumeEvent::getPlayer怎么用?PHP PlayerItemConsumeEvent::getPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerItemConsumeEvent
的用法示例。
在下文中一共展示了PlayerItemConsumeEvent::getPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: playerItemConsume
public function playerItemConsume(PlayerItemConsumeEvent $event)
{
$player = $event->getPlayer();
if ($player->getGamemode() == 0) {
$item = $event->getItem();
$item_consumed = $item->getID();
if ($this->isExistsItem($item_consumed)) {
$event->setCancelled();
$count = $item->getCount();
if ($count == 1) {
$item = Item::get(0, 0, 0);
} else {
$item->setCount($count - 1);
}
$player->getInventory()->setItemInHand($item);
if ($item_consumed == 367 || $item_consumed == 365) {
if ($this->setPlayerPoisoned($player->getDisplayName(), $this->poison[$item_consumed]) == true) {
$this->chat($player, "You have been poisoned by food", 4);
}
}
$var = $this->items[$item_consumed];
$this->addFoodLevel($player, $var[0]);
$this->addFoodSaturationLevel($player, $var[1]);
$this->test($player->getDisplayName());
}
}
}
示例2: eat
public function eat(PlayerItemConsumeEvent $ev)
{
$p = $ev->getPlayer();
if ($ev->getItem()->getId() === 322) {
$p->addEffect(Effect::getEffect(10)->setAmplifier(4)->setDuration(100)->setVisible(true));
$p->addEffect(Effect::getEffect(21)->setAmplifier(2)->setDuration(20 * 120)->setVisible(true));
}
}
示例3: onEat
public function onEat(Eat $e)
{
$p = $e->getPlayer();
//How to get a player. Simple if you want to do things when the function is used.
$item = $e->getItem();
$id = $item->getId();
if ($id == 364) {
$p->sendMessage("Ayyy me amigooo! You just ate a tacoooo!");
//Sends the player a message when they eat the "taco" (Its actually steak)
}
}
示例4: onItemConsume
public function onItemConsume(PlayerItemConsumeEvent $event)
{
if ($this->plugin->getConfig()->getAll()["block-all-events"]) {
if (!ServerAuth::getAPI()->isPlayerRegistered($event->getPlayer()->getName()) || !ServerAuth::getAPI()->isPlayerAuthenticated($event->getPlayer())) {
$event->setCancelled(true);
}
}
}
示例5: onPlayerItemConsume
/**
* @param PlayerItemConsumeEvent $event
*
* @priority LOWEST
*/
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
if (!$this->auth->isPlayerAuthenticated($event->getPlayer())) {
$event->setCancelled(true);
}
}
示例6: onPlayerEat
public function onPlayerEat(pic $ev)
{
$p = $ev->getPlayer();
$i = $ev->getItem();
switch ($this->phase) {
case 0:
//Waiting in the lobby
//Waiting in the lobby
case 1:
//Starting the game
$ev->setCancelled();
break;
case 2:
case 3:
if ($i->getId() == Item::GOLDEN_APPLE) {
$p->addEffect(Effect::getEffect(6)->setAmplifier(1)->setDuration(4));
}
break;
}
}
示例7: onConsume
public function onConsume(PlayerItemConsumeEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$pl = $ev->getPlayer();
if ($pl->hasPermission("wp.banitem.exempt")) {
return;
}
$world = $pl->getLevel()->getName();
if (!isset($this->wcfg[$world])) {
return;
}
$item = $ev->getItem();
if (!isset($this->wcfg[$world][$item->getId()])) {
return;
}
$pl->sendMessage(mc::_("You can not use that item here!"));
$ev->setCancelled();
}
示例8: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
if ($event->getItem()->getId() === Item::MUSHROOM_STEW) {
$playerGameId = $this->players[$event->getPlayer()->getName()];
if ($playerGameId === "NONE") {
return true;
}
$this->games[$playerGameId]->useMedicine($event->getPlayer()->getName());
$event->getPlayer()->sendMessage(TextFormat::GREEN . $this->getTranslation("MEDICINE_USED"));
}
return true;
}
示例9: onConsume
public function onConsume(PlayerItemConsumeEvent $ev)
{
$this->checkPlenty($ev->getPlayer(), $ev->getItem());
}
示例10: onFoodEat
public function onFoodEat(PlayerItemConsumeEvent $event)
{
if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] !== true) {
$event->setCancelled(true);
} elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
$event->setCancelled(true);
$event->getPlayer()->sendMessage($this->disable);
}
}
示例11: onEat
public function onEat(PlayerItemConsumeEvent $event)
{
$user = $this->main->getUserByPlayer($event->getPlayer());
if ($user === null or !$user->isPlaying()) {
$event->setCancelled();
}
}
示例12: onPlayerItemConsume
public function onPlayerItemConsume(\pocketmine\event\player\PlayerItemConsumeEvent $event)
{
if (!$this->isLogin($event->getPlayer())) {
$event->setCancelled();
}
}
示例13: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
$event->setCancelled($this->isLogin($event->getPlayer()) ? false : true);
}
示例14: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
if (!$this->isValidPlayer($event->getPlayer())) {
return;
}
if ($this->players[$event->getPlayer()->getName()]->getSkillByItem($event->getItem()) !== null) {
$event->setCancelled();
}
}
示例15: onPlayerItemConsume
public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
{
if (isset($this->needAuth[$event->getPlayer()->getName()])) {
$event->setCancelled();
$this->deauthenticatePlayer($event->getPlayer());
}
}