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


PHP PlayerMoveEvent::getFrom方法代码示例

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


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

示例1: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $from = $event->getFrom();
     $to = $event->getTo();
     if ($from->getLevel()->getBlockIdAt($from->x, $from->y - 1, $from->z) === Block::REDSTONE_BLOCK) {
         $player->setMotion((new Vector3($to->x - $from->x, $to->y - $from->y, $to->z - $from->z))->multiply(5));
     }
 }
开发者ID:somenabzofturtles,项目名称:Small-PM-Plugins,代码行数:9,代码来源:Main.php

示例2: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     if (isset($this->move[$event->getPlayer()->getName()])) {
         unset($this->move[$event->getPlayer()->getName()]);
         return;
     }
     if ($event->getFrom()->distance($event->getTo()) > 7) {
         $event->setCancelled();
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:10,代码来源:placebo.php

示例3: onMove

 public function onMove(PlayerMoveEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $from = $ev->getFrom();
     $to = $ev->getTo();
     $dir = ["dx" => $to->getX() - $from->getX(), "dy" => $to->getY() - $from->getY(), "dz" => $to->getZ() - $from->getZ()];
     if (!$dir["dy"]) {
         return;
     }
     $id = $to->getLevel()->getBlockIdAt($to->getX(), $to->getY() - 1, $to->getZ());
     if (isset($this->blocks[$id])) {
         $ev->getPlayer()->setMotion(new Vector3($dir["dx"], -$dir["dy"] * 1.1, $dir["dz"]));
     }
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:16,代码来源:Trampoline.php

示例4: onMove

 /**
  * @param PlayerMoveEvent $event
  *
  * @priority HIGHEST
  */
 public function onMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $gamer = $this->hub->getGamerForPlayer($player);
     $delta = $event->getTo()->subtract($event->getFrom());
     $bb = clone $player->getBoundingBox();
     $bb->offset($delta->x, $delta->y, $delta->z);
     foreach ($this->hub->getJoinMethods() as $method) {
         if (!$method->isLevelCorrect($player->getLevel())) {
             continue;
         }
         if ($method instanceof PortalJoinMethod) {
             if ($method->isLevelCorrect($player->getLevel()) and $method->bb->intersectsWith($bb)) {
                 $gamer->setModule($this->hub->getModule($method->target));
                 return;
             }
         }
     }
 }
开发者ID:gitter-badger,项目名称:DynamicHub,代码行数:24,代码来源:JoinListener.php

示例5: onMove

 /**
  * Handle player move events.
  * @param PlayerMoveEvent $ev - Move event
  */
 public function onMove(PlayerMoveEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $p = $ev->getPlayer();
     if (!$this->getState("fz", $p, false)) {
         return;
     }
     if ($this->hard) {
         $ev->setCancelled();
     } else {
         // Lock position but still allow to turn around
         $to = clone $ev->getFrom();
         $to->yaw = $ev->getTo()->yaw;
         $to->pitch = $ev->getTo()->pitch;
         $ev->setTo($to);
     }
 }
开发者ID:HeechFive,项目名称:pocketmine-plugins,代码行数:24,代码来源:FreezeSession.php

示例6: onPlayerTeleport

 public function onPlayerTeleport(PlayerMoveEvent $event)
 {
     if ($event->getFrom()->getLevel() !== $event->getTo()->getLevel()) {
         $to = $event->getTo()->getLevel();
         if (isset($this->items[$to->getFolderName()])) {
             $player = $event->getPlayer();
             foreach ($this->items[$to->getFolderName()] as $displayer) {
                 $displayer->spawnTo($player);
             }
         }
     }
 }
开发者ID:PocketMine-PHP7,项目名称:EconomyS-PHP7,代码行数:12,代码来源:EconomyShop.php

示例7: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if ($event->getFrom()->getLevel() === $event->getTo()->getLevel()) {
         return;
     }
     $this->checkItemCase($event->getPlayer());
 }
开发者ID:HelloWorld017,项目名称:xChange,代码行数:7,代码来源:ExchangeItem.php

示例8: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if (!$this->plugin->getConfig()->get("ShowPlotPopup", true)) {
         return;
     }
     $levelName = $event->getPlayer()->getLevel()->getName();
     if (!$this->plugin->isLevelLoaded($levelName)) {
         return;
     }
     $plot = $this->plugin->getPlotByPosition($event->getTo());
     if ($plot !== null and $plot !== $this->plugin->getPlotByPosition($event->getFrom())) {
         $plotName = TextFormat::GREEN . $plot;
         $popup = $this->plugin->getLanguage()->translateString("popup", [$plotName]);
         if ($plot->owner != "") {
             $owner = TextFormat::GREEN . $plot->owner;
             $ownerPopup = $this->plugin->getLanguage()->translateString("popup.owner", [$owner]);
             $paddingSize = floor((strlen($popup) - strlen($ownerPopup)) / 2);
             $paddingPopup = str_repeat(" ", max(0, -$paddingSize));
             $paddingOwnerPopup = str_repeat(" ", max(0, $paddingSize));
             $popup = TextFormat::WHITE . $paddingPopup . $popup . "\n" . TextFormat::WHITE . $paddingOwnerPopup . $ownerPopup;
         }
         $event->getPlayer()->sendTip($popup);
     }
 }
开发者ID:Adam1609,项目名称:MyPlot,代码行数:24,代码来源:EventListener.php

示例9: onMoveEvent

 public function onMoveEvent(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     if (($fromLevel = $event->getFrom()->getLevel()->getFolderName()) !== ($toLevel = $event->getTo()->getLevel()->getFolderName())) {
         if (isset($this->worlds[$toLevel])) {
             $this->players[$event->getPlayer()->getName()] = $toLevel;
             $this->getWorldManagerByWorldFolderName($toLevel)->onPlayerMoveToWorld($event->getPlayer());
         }
         if (isset($this->worlds[$fromLevel])) {
             if ($this->players[$event->getPlayer()->getName()] === $fromLevel) {
                 $this->players[$event->getPlayer()->getName()] = $this->getServer()->getDefaultLevel()->getFolderName();
             }
             $this->getWorldManagerByWorldFolderName($fromLevel)->onPlayerMoveToAnotherWorld($event->getPlayer(), $toLevel);
         }
         foreach ($this->npcs as $npc) {
             if ($npc->getLevel()->getFolderName() === $toLevel) {
                 $npc->spawnTo($player);
             }
         }
     }
     if (isset($this->worlds[$toLevel])) {
         if ($event->getTo()->getY() <= $this->getConfiguration("MIN_Y")) {
             $this->worlds[$toLevel]["manager"]->onPlayerDrown($event->getPlayer());
         }
     }
     foreach ($this->npcs as $npc) {
         if ($npc->getLevel()->getFolderName() === $event->getPlayer()->getLevel()->getFolderName()) {
             $npc->seePlayer($player);
         }
     }
 }
开发者ID:HelloWorld017,项目名称:SkyFall,代码行数:31,代码来源:FreedomDive.php

示例10: onMove

 public function onMove(PlayerMoveEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $p = $ev->getPlayer();
     if (isset($this->frosties[strtolower($p->getName())])) {
         if ($this->hard) {
             $ev->setCancelled();
             if (MPMU::apiVersion("1.12.0")) {
                 $p->sendTip(mc::_("You are frozen"));
             }
         } else {
             // Lock position but still allow to turn around
             $to = clone $ev->getFrom();
             $to->yaw = $ev->getTo()->yaw;
             $to->pitch = $ev->getTo()->pitch;
             $ev->setTo($to);
             if (MPMU::apiVersion("1.12.0")) {
                 $p->sendTip(mc::_("You are frozen in place"));
             }
         }
     }
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:25,代码来源:CmdFreezeMgr.php

示例11: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     if (!isset(self::$players[$player->getName()])) {
         return;
     }
     $xcelPlayer = self::$players[$player->getName()];
     if (($fromLevel = $event->getFrom()->getLevel()->getFolderName()) !== ($toLevel = $event->getTo()->getLevel()->getFolderName())) {
         if ($xcelPlayer->getGame() !== null) {
             $xcelPlayer->getGame()->onPlayerMoveToAnotherWorld($xcelPlayer);
         }
         if (isset(self::$worlds[$toLevel])) {
             self::$worlds[$toLevel]->warpPlayerTo($xcelPlayer);
         }
     }
 }
开发者ID:organization,项目名称:XcelNgien,代码行数:16,代码来源:XcelNgien.php

示例12: onMove

 public function onMove(PlayerMoveEvent $e)
 {
     $p = $e->getPlayer();
     if ($this->inArena($p) && $this->game === 0 && (floor($e->getFrom()->x) !== floor($e->getTo()->x) || floor($e->getFrom()->z) !== floor($e->getTo()->z))) {
         $e->setCancelled();
         return;
     }
     if ($this->game > 1) {
         $e->getHandlers()->unregister($this);
     }
 }
开发者ID:ChiefArtz,项目名称:SurvivalGames,代码行数:11,代码来源:Arena.php

示例13: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $x = round($event->getFrom()->x);
     $y = round($event->getFrom()->y);
     $z = round($event->getFrom()->z);
     foreach ($this->plugin->getAvailableLevels() as &$lv) {
         if ($lv instanceof GameLevelModel) {
             if ($lv->status === GameLevelModel::STATUS_AVAILABLE) {
                 if ($player->getLevel()->getName() != $lv->levelName) {
                     continue;
                 }
                 if ($lv->portalEnter($this->plugin, $lv, $player)) {
                     return;
                     break;
                 }
             } elseif ($lv->currentStep === GameLevelModel::STEP_WAITING) {
                 if (strtolower($player->level->getName()) === strtolower($lv->currentMap->levelName)) {
                     $player->onGround = true;
                     $event->setCancelled(true);
                 } else {
                     $player->onGround = false;
                 }
                 break;
             }
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:28,代码来源:GameLevelListener.php

示例14: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $Player = $event->getPlayer();
     $Level = $Player->getLevel();
     if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName()) {
         return;
     }
     if ($Player->getGamemode() == Player::SPECTATOR) {
         return;
     }
     $event->setCancelled($this->plugin->game->PlayerMove($event->getPlayer(), $event->getFrom(), $event->getTo()));
     $X = $Player->getFloorX();
     $Y = intval($Player->getY());
     $Z = $Player->getFloorZ();
     $Block = $Level->getBlock(new Vector3($X, $Y, $Z));
     if ($Block->getId() == 133) {
         $Player->setMotion(new Vector3(0, 0, 0));
     } elseif ($Block->getId() == 44 && $Block->getDamage() % 8 == 4) {
         $Player->setMotion(new Vector3(rand(-50, 50) / 50, rand(100, 250) / 100, rand(-50, 50) / 50));
         $Level->setBlock(new Vector3($X, $Y, $Z), Block::get(0), true, true);
     } elseif ($Block->getId() == 96 && $Block->getDamage() < 4) {
         $Level->getBlock(new Vector3($X, $Y, $Z))->onActivate(Item::get(0));
     }
 }
开发者ID:MateiGamingYTB,项目名称:BedWarsPE,代码行数:24,代码来源:EventListener.php

示例15: mon_onMove

 public function mon_onMove(PlayerMoveEvent $event)
 {
     $game = Settings::portal($this->getPlayer(), $this->main);
     if ($game instanceof Game) {
         $this->getPlayer()->getInventory()->clearAll();
         if ($game->onJoin($this)) {
             $this->tell("You have entered the game: %s", $game->getName());
             $this->switchSession($game->getSessionId());
         } else {
             $this->tell("You are refused to enter this game!");
         }
     } else {
         Settings::portalBoost2($this->getPlayer());
         $from = Settings::checkInvisibility($event->getFrom());
         $to = Settings::checkInvisibility($event->getTo());
         if ($from and !$to) {
             $this->setVisible(self::INVISIBLE_SPAWN);
         } elseif (!$from and $to) {
             $this->setInvisible(self::INVISIBLE_SPAWN);
         }
     }
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:22,代码来源:Session.php


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