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


PHP Server::getOps方法代码示例

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


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

示例1: useItemOn

 /**
  * Uses a item on a position and face, placing it or activating the block
  *
  * @param Vector3 $vector
  * @param Item    $item
  * @param int     $face
  * @param float   $fx     default 0.0
  * @param float   $fy     default 0.0
  * @param float   $fz     default 0.0
  * @param Player  $player default null
  *
  * @return boolean
  */
 public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null)
 {
     $target = $this->getBlock($vector);
     $block = $target->getSide($face);
     if ($block->y > 127 or $block->y < 0) {
         return false;
     }
     if ($target->getId() === Item::AIR) {
         return false;
     }
     if ($player instanceof Player) {
         $ev = new PlayerInteractEvent($player, $item, $target, $face, $target->getId() === 0 ? PlayerInteractEvent::RIGHT_CLICK_AIR : PlayerInteractEvent::RIGHT_CLICK_BLOCK);
         if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if (count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if (!$ev->isCancelled()) {
             $target->onUpdate(self::BLOCK_UPDATE_TOUCH);
             if ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
                 return true;
             }
             if ($item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
                 if ($item->getCount() <= 0) {
                     $item = Item::get(Item::AIR, 0, 0);
                     return true;
                 }
             }
         } else {
             return false;
         }
     } elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
         return true;
     }
     if ($item->isPlaceable()) {
         $hand = $item->getBlock();
         $hand->position($block);
     } elseif ($block->getId() === Item::FIRE) {
         $this->setBlock($block, new Air(), true);
         return false;
     } else {
         return false;
     }
     if (!($block->canBeReplaced() === true or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
         return false;
     }
     if ($target->canBeReplaced() === true) {
         $block = $target;
         $hand->position($block);
         //$face = -1;
     }
     if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
         $entities = $this->getCollidingEntities($hand->getBoundingBox());
         $realCount = 0;
         foreach ($entities as $e) {
             if ($e instanceof Arrow or $e instanceof DroppedItem) {
                 continue;
             }
             ++$realCount;
         }
         if ($realCount > 0) {
             return false;
             //Entity in block
         }
     }
     if ($player instanceof Player) {
         $ev = new BlockPlaceEvent($player, $hand, $block, $target, $item);
         if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if (count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             return false;
         }
     }
     if ($hand->place($item, $block, $target, $face, $fx, $fy, $fz, $player) === false) {
         return false;
     }
//.........这里部分代码省略.........
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:101,代码来源:Level.php

示例2: useItemOn

 /**
  * Uses a item on a position and face, placing it or activating the block
  *
  * @param Vector3 $vector
  * @param Item    $item
  * @param int     $face
  * @param float   $fx     default 0.0
  * @param float   $fy     default 0.0
  * @param float   $fz     default 0.0
  * @param Player  $player default null
  *
  * @return boolean
  */
 public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null)
 {
     $target = $this->getBlock($vector);
     $block = $target->getSide($face);
     if ($block->y > 127 or $block->y < 0) {
         return false;
     }
     if ($target->getId() === Item::AIR) {
         return false;
     }
     if ($player !== null) {
         $ev = new PlayerInteractEvent($player, $item, $target, $face, $target->getId() === 0 ? PlayerInteractEvent::RIGHT_CLICK_AIR : PlayerInteractEvent::RIGHT_CLICK_BLOCK);
         if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if (count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if (!$ev->isCancelled()) {
             $target->onUpdate(self::BLOCK_UPDATE_TOUCH);
             if (!$player->isSneaking() and $target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
                 return true;
             }
             if (!$player->isSneaking() and $item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
                 if ($item->getCount() <= 0) {
                     $item = Item::get(Item::AIR, 0, 0);
                     return true;
                 }
             }
         } else {
             return false;
         }
     } elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
         return true;
     }
     if ($item->canBePlaced()) {
         $hand = $item->getBlock();
         $hand->position($block);
     } elseif ($block->getId() === Item::FIRE) {
         $this->setBlock($block, new Air(), true);
         return false;
     } else {
         return false;
     }
     if (!($block->canBeReplaced() === true or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
         return false;
     }
     if ($target->canBeReplaced() === true) {
         $block = $target;
         $hand->position($block);
         //$face = -1;
     }
     if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
         $entities = $this->getCollidingEntities($hand->getBoundingBox());
         $realCount = 0;
         foreach ($entities as $e) {
             if ($e instanceof Arrow or $e instanceof DroppedItem) {
                 continue;
             }
             ++$realCount;
         }
         if ($player !== null) {
             if ($diff = $player->getNextPosition()->subtract($player->getPosition()) and $diff->lengthSquared() > 1.0E-5) {
                 $bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
                 if ($hand->getBoundingBox()->intersectsWith($bb)) {
                     ++$realCount;
                 }
             }
         }
         if ($realCount > 0) {
             return false;
             //Entity in block
         }
     }
     $tag = $item->getNamedTagEntry("CanPlaceOn");
     if ($tag instanceof Enum) {
         $canPlace = false;
         foreach ($tag as $v) {
             if ($v instanceof String) {
                 $entry = Item::fromString($v->getValue());
                 if ($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()) {
                     $canPlace = true;
                     break;
                 }
//.........这里部分代码省略.........
开发者ID:robozeri,项目名称:Yuriko-MP,代码行数:101,代码来源:Level.php

示例3: useItemOn

 /**
  * Uses a item on a position and face, placing it or activating the block
  *
  * @param Vector3 $vector
  * @param Item    $item
  * @param int     $face
  * @param float   $fx     default 0.0
  * @param float   $fy     default 0.0
  * @param float   $fz     default 0.0
  * @param Player  $player default null
  *
  * @return bool
  */
 public function useItemOn(Vector3 $vector, Item &$item, int $face, float $fx = 0.0, float $fy = 0.0, float $fz = 0.0, Player $player = null) : bool
 {
     $target = $this->getBlock($vector);
     $block = $target->getSide($face);
     if ($block->y > 127 or $block->y < 0) {
         return false;
     }
     if ($target->getId() === Item::AIR) {
         return false;
     }
     if ($player !== null) {
         $ev = new PlayerInteractEvent($player, $item, $target, $face, $target->getId() === 0 ? PlayerInteractEvent::RIGHT_CLICK_AIR : PlayerInteractEvent::RIGHT_CLICK_BLOCK);
         if (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if (count($this->server->getOps()->getAll()) > 0 and $t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if (!$ev->isCancelled()) {
             $target->onUpdate(self::BLOCK_UPDATE_TOUCH);
             if (!$player->isSneaking() and $target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
                 return true;
             }
             if (!$player->isSneaking() and $item->canBeActivated() and $item->onActivate($this, $player, $block, $target, $face, $fx, $fy, $fz)) {
                 if ($item->getCount() <= 0) {
                     $item = Item::get(Item::AIR, 0, 0);
                     return true;
                 }
             }
         } else {
             return false;
         }
     } elseif ($target->canBeActivated() === true and $target->onActivate($item, $player) === true) {
         return true;
     }
     if ($item->canBePlaced()) {
         $hand = $item->getBlock();
         $hand->position($block);
     } else {
         return false;
     }
     if (!($block->canBeReplaced() === true or $hand->getId() === Item::WOOD_SLAB and $block->getId() === Item::WOOD_SLAB or $hand->getId() === Item::SLAB and $block->getId() === Item::SLAB)) {
         return false;
     }
     if ($target->canBeReplaced() === true) {
         $block = $target;
         $hand->position($block);
         //$face = -1;
     }
     if ($hand->isSolid() === true and $hand->getBoundingBox() !== null) {
         $entities = $this->getCollidingEntities($hand->getBoundingBox());
         $realCount = 0;
         foreach ($entities as $e) {
             if ($e instanceof Arrow or $e instanceof DroppedItem) {
                 continue;
             }
             ++$realCount;
         }
         if ($player !== null) {
             if ($diff = $player->getNextPosition()->subtract($player->getPosition()) and $diff->lengthSquared() > 1.0E-5) {
                 $bb = $player->getBoundingBox()->getOffsetBoundingBox($diff->x, $diff->y, $diff->z);
                 if ($hand->getBoundingBox()->intersectsWith($bb)) {
                     ++$realCount;
                 }
             }
         }
         if ($realCount > 0) {
             return false;
             //Entity in block
         }
     }
     $tag = $item->getNamedTagEntry("CanPlaceOn");
     if ($tag instanceof ListTag) {
         $canPlace = false;
         foreach ($tag as $v) {
             if ($v instanceof StringTag) {
                 $entry = Item::fromString($v->getValue());
                 if ($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()) {
                     $canPlace = true;
                     break;
                 }
             }
         }
         if (!$canPlace) {
//.........这里部分代码省略.........
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:101,代码来源:Level.php


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