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


PHP PlayerBedEnterEvent::isCancelled方法代码示例

本文整理汇总了PHP中pocketmine\event\player\PlayerBedEnterEvent::isCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerBedEnterEvent::isCancelled方法的具体用法?PHP PlayerBedEnterEvent::isCancelled怎么用?PHP PlayerBedEnterEvent::isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\player\PlayerBedEnterEvent的用法示例。


在下文中一共展示了PlayerBedEnterEvent::isCancelled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onPlayerInteract

 /**
  * @priority HIGHEST
  */
 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $p = $event->getPlayer();
     $b = $event->getBlock();
     if ($b->getID() !== 26) {
         return;
     }
     $event->setCancelled();
     $xTabel = [3 => 1, 1 => -1];
     $b = $b->getSide(5, isset($xTabel[$dmg = $b->getDamage()]) ? $xTabel[$dmg] : 0);
     $zTabel = [0 => 1, 2 => -1];
     $b = $b->getSide(3, isset($zTabel[$dmg]) ? $zTabel[$dmg] : 0);
     $this->getServer()->getPluginManager()->callEvent($ev = new PlayerBedEnterEvent($p, $b));
     if ($ev->isCancelled()) {
         return;
     }
     $property = (new \ReflectionClass("\\pocketmine\\Player"))->getProperty("sleeping");
     $property->setAccessible(true);
     foreach ($p->getLevel()->getNearbyEntities($p->getBoundingBox()->grow(2, 1, 2), $p) as $pl) {
         if ($pl instanceof Player && $pl->isSleeping()) {
             if ($b->distance($property->getValue($pl)) <= 0.1) {
                 $p->sendMessage("This bed is occupied");
                 return;
             }
         }
     }
     $property->setValue($p, $b);
     $p->teleport($b->add(0.5, 0.5, 0.5));
     $p->sendMetadata($p->getViewers());
     $p->sendMetadata($p);
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:37,代码来源:HealBed.php

示例2: sleepOn

 /**
  * @param Vector3 $pos
  *
  * @return boolean
  */
 public function sleepOn(Vector3 $pos)
 {
     if (!$this->isOnline()) {
         return false;
     }
     foreach ($this->level->getNearbyEntities($this->boundingBox->grow(2, 1, 2), $this) as $p) {
         if ($p instanceof Player) {
             if ($p->sleeping !== null and $pos->distance($p->sleeping) <= 0.1) {
                 return false;
             }
         }
     }
     $this->server->getPluginManager()->callEvent($ev = new PlayerBedEnterEvent($this, $this->level->getBlock($pos)));
     if ($ev->isCancelled()) {
         return false;
     }
     $this->sleeping = clone $pos;
     $this->teleport(new Position($pos->x + 0.5, $pos->y - 0.5, $pos->z + 0.5, $this->level));
     $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [$pos->x, $pos->y, $pos->z]);
     $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, true);
     $this->setSpawn($pos);
     $this->level->sleepTicks = 60;
     return true;
 }
开发者ID:NewDelion,项目名称:PocketMine-0.13.x,代码行数:29,代码来源:Player.php

示例3: sleepOn

 /**
  * @param Vector3 $pos
  *
  * @return boolean
  */
 public function sleepOn(Vector3 $pos)
 {
     foreach ($this->level->getNearbyEntities($this->boundingBox->grow(2, 1, 2), $this) as $p) {
         if ($p instanceof Player) {
             if ($p->sleeping !== null and $pos->distance($p->sleeping) <= 0.1) {
                 return false;
             }
         }
     }
     $this->server->getPluginManager()->callEvent($ev = new PlayerBedEnterEvent($this, $this->level->getBlock($pos)));
     if ($ev->isCancelled()) {
         return false;
     }
     $this->sleeping = clone $pos;
     $this->setDataProperty(self::DATA_PLAYER_BED_POSITION, self::DATA_TYPE_POS, [$pos->x, $pos->y, $pos->z]);
     $this->setDataFlag(self::DATA_PLAYER_FLAGS, self::DATA_PLAYER_FLAG_SLEEP, true);
     $this->setSpawn($pos);
     $this->tasks[] = $this->server->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "checkSleep"]), 60);
     return true;
 }
开发者ID:ZenaGamingsky,项目名称:Steadfast2,代码行数:25,代码来源:Player.php

示例4: sleepOn

 /**
  * @param Vector3 $pos
  *
  * @return boolean
  */
 public function sleepOn(Vector3 $pos)
 {
     foreach ($this->level->getNearbyEntities($this->boundingBox->grow(2, 1, 2), $this) as $p) {
         if ($p instanceof Player) {
             if ($p->sleeping !== null) {
                 if ($pos->distance($p->sleeping) <= 0.1) {
                     return false;
                 }
             }
         }
     }
     $this->server->getPluginManager()->callEvent($ev = new PlayerBedEnterEvent($this, $this->level->getBlock($pos)));
     if ($ev->isCancelled()) {
         return false;
     }
     $this->sleeping = clone $pos;
     $this->teleport(new Position($pos->x + 0.5, $pos->y + 1, $pos->z + 0.5, $this->level));
     $this->sendMetadata($this->getViewers());
     $this->sendMetadata($this);
     $this->setSpawn($pos);
     $this->tasks[] = $this->server->getScheduler()->scheduleDelayedTask(new CallbackTask([$this, "checkSleep"]), 60);
     return true;
 }
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:28,代码来源:Player.php


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