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


PHP PlayerMoveEvent::getPlayer方法代码示例

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


在下文中一共展示了PlayerMoveEvent::getPlayer方法的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

 /** 
  * @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

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

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

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

示例8: onPlayerMove

 public function onPlayerMove(PlayerMoveEvent $event)
 {
     if (isset($this->activeZones[$event->getPlayer()->getLevel()->getId()])) {
         foreach ($this->activeZones[$event->getPlayer()->getLevel()->getId()] as $zone) {
             if ($this->isInsideZone($event->getTo(), $zone[0], $zone[1])) {
                 $event->setCancelled();
                 $event->getPlayer()->sendMessage("You can't go in there, a mine is resetting.");
                 return;
             }
         }
     }
 }
开发者ID:MCPEGamerJPatGitHub,项目名称:MineReset,代码行数:12,代码来源:RegionBlocker.php

示例9: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     foreach ($this->tntRun->arenas as $arena) {
         if ($arena->getPlayerManager()->isPlaying($event->getPlayer()) && $arena->getStatusManager()->isRunning()) {
             $p = $event->getPlayer();
             $p->getServer()->getScheduler()->scheduleDelayedTask(new UnsetBlockTask($this->tntRun, $p->getLevel()->getBlock(new Vector3($p->getFloorX(), $p->getFloorY() - 1, $p->getFloorZ()))), 40);
             if ($p->y < $arena->getStructureManager()->getLowestFloorY()) {
                 $arena->getPlayerHandler()->leavePlayer($p);
             }
             return;
         }
     }
 }
开发者ID:EmreTr1,项目名称:TNTRun,代码行数:13,代码来源:EventListener.php

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

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

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

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

示例14: onMove

 public function onMove(PlayerMoveEvent $event)
 {
     $cfg = $this->getConfig();
     $player = $event->getPlayer();
     $c4 = $event->getPlayer()->getLevel()->getBlock($event->getPlayer()->floor()->subtract(0, 1));
     $e = new Explosion($player, $cfg->get("Explosion-Radius"));
     if ($c4->getId() === $cfg->get("C4-Block")) {
         if ($cfg->get("Remove-Terrain") == true) {
             $player->sendMessage(TextFormat::YELLOW . "[C-4]" . TextFormat::RED . " Booom!!");
             $e->explodeA();
             $e->explodeB();
         } else {
             $player->sendMessage(TextFormat::YELLOW . "[C-4]" . TextFormat::RED . " Booom!!");
             $e->explodeB();
         }
     }
 }
开发者ID:Skull3x,项目名称:C4-Explosion,代码行数:17,代码来源:Main.php

示例15: onVoidLoop

 public function onVoidLoop(PlayerMoveEvent $event)
 {
     if ($event->getTo()->getFloorY() < 1) {
         $player = $event->getPlayer();
         $name = $event->getPlayer()->getName();
         $name = strtolower($name);
         $pos = $this->data->get($name);
         if (is_array($pos)) {
             $player->sendMessage("{$this->getConfig()->get("TeleportMessage")}");
             $level = $this->getServer()->getLevelByName($pos[3]);
             $player->teleport(new Position($pos[0], $pos[1], $pos[2], $level));
         } else {
             $player->sendMessage("{$this->getConfig()->get("No-Checkpoint")}");
             $player->teleport($player->getLevel()->getSafeSpawn());
         }
     }
 }
开发者ID:linuzo,项目名称:Parkour,代码行数:17,代码来源:Main.php


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