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


PHP player\PlayerMoveEvent类代码示例

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


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

示例1: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $world = $player->getLevel();
     $block = $world->getBlock($player->floor()->subtract(0, 1));
     if ($world->getName() == $this->getHotBlock()->getConfig()->get("world")) {
         switch ($block->getId()) {
             case Block::PLANKS:
                 $player->sendTip("§aYou're safe!");
                 break;
             case Block::END_STONE:
                 $player->sendTip("§eGo!");
                 break;
             case Block::NETHERRACK:
                 $player->sendTip("§cYou'll poisoned!");
                 $effect = Effect::getEffect(Effect::POISON);
                 $effect->setVisible(true);
                 $effect->setDuration(50);
                 $player->addEffect($effect);
                 break;
             case Block::QUARTZ_BLOCK:
                 if (count($world->getPlayers()) < $this->getHotBlock()->getConfig()->get("players")) {
                     $player->sendTip("§cThere must be " . $this->getHotBlock()->getConfig()->get("players") . "players online");
                 } else {
                     $player->sendTip("§eYou're standing on the §l§cHot§6Block§r§e! §bMove!");
                     $this->getHotBlock()->getEconomy()->addMoney($player, 1, false, "HotBlock");
                     $player->sendPopup("§eYou have §a" . $this->getHotBlock()->getEconomy()->myMoney($player) . " §bCoins");
                 }
                 break;
         }
     }
 }
开发者ID:jjplaying,项目名称:HotBlock,代码行数:32,代码来源:EventListener.php

示例2: onPlayerMoveEvent

 public function onPlayerMoveEvent(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->isSpectator()) {
         return;
     }
     $attribute = AttributeProvider::getInstance()->getAttribute($player);
     if ($attribute->getCTick() <= 20) {
         $attribute->setCTick($attribute->getCTick() + 1);
     }
     if ($attribute->getCTick() > 20) {
         $attribute->setCTick(0);
     }
     foreach ($player->getLevel()->getNearbyEntities($player->getBoundingBox()->grow(1, 0.5, 1), $player) as $entity) {
         if (!$entity->isAlive()) {
             continue;
         }
         if (!$entity instanceof ExperienceOrb) {
             continue;
         }
         $pk = new TakeItemEntityPacket();
         $pk->eid = $player->getId();
         $pk->target = $entity->getId();
         Server::broadcastPacket($entity->getViewers(), $pk);
         $pk = new TakeItemEntityPacket();
         $pk->eid = 0;
         $pk->target = $player->getId();
         $player->dataPacket($pk);
         $entity->kill();
         $attribute->addExp($entity->getExp());
     }
     if ($player->isSprinting()) {
         if ($attribute->getCTick() == 20) {
             HungerSystem::exhaustion($player, HungerSystem::SPRINTING);
         }
     } else {
         if ($player->isSneaking()) {
             if ($attribute->getCTick() == 20) {
                 HungerSystem::exhaustion($player, HungerSystem::WALKING_AND_SNEAKING);
             }
         }
     }
     if ($player->isInsideOfWater()) {
         if ($attribute->getCTick() == 20) {
             HungerSystem::exhaustion($player, HungerSystem::SWIMMING);
         }
     }
 }
开发者ID:iJoshuaHD,项目名称:PlayHarder,代码行数:48,代码来源:EventListener.php

示例3: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     if ($this->getPlugin()->isFrozen($event->getPlayer())) {
         $event->setCancelled(true);
         $event->getPlayer()->sendTip("§cI'm sorry that you cannot move,\n§cbut you are frozen!");
     }
 }
开发者ID:tankisu01,项目名称:AdminFun,代码行数:7,代码来源:FreezeListener.php

示例4: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     if ($player == null) {
         return;
     }
     if ($player->getLevel() == null) {
         return;
     }
     // under
     $x = (int) round($player->x - 0.5);
     $y = (int) round($player->y - 1);
     $z = (int) round($player->z - 0.5);
     $id = $player->getLevel()->getBlockIdAt($x, $y, $z);
     $data = $player->getLevel()->getBlockDataAt($x, $y, $z);
     switch ($id) {
         case 35:
             if ($data == 1) {
                 $player->getInventory()->addItem(new Item(ITEM::COOKIE, 0, 1));
                 $player->sendPopup(TextFormat::GRAY . "GiveCookie:\n" . TextFormat::YELLOW . "> " . TextFormat::GREEN . "You've received a cookie!");
             }
             break;
         default:
             break;
     }
 }
开发者ID:ZINGDING,项目名称:GiveCookie,代码行数:26,代码来源:Main.php

示例5: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     if ($player instanceof Player) {
         if ($player->getLevel()->getName() === $this->plugin->vipLevelName) {
             if (isset($this->plugin->statueManager->npcsSpawns[$player->getName()])) {
                 return;
             }
             foreach ($this->plugin->statueManager->npcs as $xnpc) {
                 if ($xnpc instanceof StatueModel) {
                     if ($player->getLevel()->getName() === $xnpc->levelName) {
                         $statuePos = $xnpc->position;
                         $pp = new Vector2(round($player->x), round($player->z));
                         $npc = new Vector2($statuePos->x, $statuePos->z);
                         $dff = abs(round($pp->distance($npc)));
                         if ($dff < 12 || $dff == 0) {
                             $builder = new StatueBuilder($this->plugin);
                             $builder->displayStatues($player, $this->plugin->statueManager->npcs);
                             $this->plugin->statueManager->npcsSpawns[$player->getName()] = $player->getName();
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:26,代码来源:StatueListener.php

示例6: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $pname = strtolower($player->getName());
     $levelName = $player->getLevel()->getName();
     $players_in_tracker = isset($this->playerLocationTracker[$pname]);
     if (!$this->plugin->isLevelLoaded($levelName)) {
         if ($players_in_tracker) {
             unset($this->playerLocationTracker[$pname]);
         }
         return;
     }
     $plot = $this->plugin->getPlotByPosition($player->getPosition());
     // if users not in a plot make sure unset
     if (is_null($plot) && $players_in_tracker) {
         unset($this->playerLocationTracker[$pname]);
         return;
     }
     if (is_null($plot)) {
         return;
     }
     // if user was not previously tracked then save pos and return
     if (!$players_in_tracker && !is_null($plot)) {
         $this->playerLocationTracker[$pname] = $plot;
         $this->plugin->getServer()->dispatchCommand($player, "p info summary");
         return;
     }
     // if user has moved
     if ($plot->X != $this->playerLocationTracker[$pname]->X || $plot->Z != $this->playerLocationTracker[$pname]->Z) {
         $this->playerLocationTracker[$pname] = $plot;
         $this->plugin->getServer()->dispatchCommand($player, "p info summary");
         return;
     }
 }
开发者ID:mwvent,项目名称:WattzMCPE-MyPlot,代码行数:34,代码来源:EventListener.php

示例7: onPlayerMove

 /** 
  * @param PlayerMoveEvent $event 
  */
 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if (!$event->isCancelled()) {
         if ($this->getPlugin()->isRocketPad($event->getPlayer()->getLevel()->getBlock($event->getPlayer()->subtract(0, 1, 0)))) {
             $this->getPlugin()->launchPlayer($event->getPlayer());
         }
     }
 }
开发者ID:Evarettedavis,项目名称:PocketMine-Plugins,代码行数:11,代码来源:RocketPadsListener.php

示例8: onPlayerMove

 /**
  * When the player move while
  * he is not logged in, cancel
  * the event
  * @param PlayerMoveEvent $event
  */
 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     if (!User::exist($player->getName()) || User::exist($player->getName()) && !User::get($player->getName())->isLogged()) {
         $event->setCancelled(true);
         $player->sendMessage($this->needLogin);
     }
 }
开发者ID:Vavaballz,项目名称:BallzAuth,代码行数:14,代码来源:LoginProtection.php

示例9: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if (!$this->plugin->getNoeulAPI()->isAuthed($event->getPlayer())) {
         $this->plugin->getNoeulAPI()->sendAuthMsg($event->getPlayer());
         $event->setCancelled(true);
         $event->getPlayer()->onGround = true;
     }
 }
开发者ID:0-Eclipse-0,项目名称:PurePerms,代码行数:8,代码来源:PPListener.php

示例10: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] === 0 && $this->plugin->allowMoving !== true) {
         $event->setCancelled(true);
     } elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
         $event->setCancelled(true);
     }
 }
开发者ID:Jackboy320,项目名称:xAuth,代码行数:8,代码来源:LoginTasks.php

示例11: onMoveEvent

 public function onMoveEvent(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     foreach ($this->npc as $npc) {
         if ($npc->getLevel()->getFolderName() === $event->getPlayer()->getLevel()->getFolderName()) {
             $npc->seePlayer($player);
         }
     }
 }
开发者ID:wodnr0804,项目名称:NPC,代码行数:9,代码来源:Main.php

示例12: 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

示例13: onPlayerMove

 /**
  * @param PlayerMoveEvent $event
  *
  * @priority LOWEST
  */
 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if (!$this->auth->isPlayerAuthenticated($event->getPlayer())) {
         if (!$event->getPlayer()->hasPermission("simpleauth.move")) {
             $event->setCancelled(true);
             $event->getPlayer()->onGround = true;
         }
     }
 }
开发者ID:jigibbs123,项目名称:pocketmine-plugins,代码行数:14,代码来源:EventListener.php

示例14: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     if ($this->past_q[$player->getName()] != $player->yaw . ":" . $player->pitch) {
         $this->past_q[$player->getName()] = $player->yaw . ":" . $player->pitch;
         return;
     }
     $this->checkMove($player, round(microtime(true) * 1000));
     $this->past_q[$player->getName()] = $player->yaw . ":" . $player->pitch;
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:10,代码来源:StartDASH.php

示例15: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $level = $player->getLevel();
     $block = Block::get($player->getInventory()->getItemInHand()->getId(), 0);
     $pos = new Vector3($player->getFloorX(), $player->getFloorY() - 1, $player->getFloorZ());
     if ($this->isPlayer($player)) {
         $level->setBlock($pos, $block);
     }
 }
开发者ID:Skull3x,项目名称:FootBlock,代码行数:10,代码来源:Main.php


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