Inheritance: extends PlayerEvent, implements pocketmine\event\Cancellable
Esempio n. 1
1
 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;
         }
     }
 }
Esempio n. 2
1
 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);
         }
     }
 }
Esempio n. 3
0
 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!");
     }
 }
Esempio n. 4
0
 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;
     }
 }
Esempio n. 5
0
 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();
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 6
0
 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;
     }
 }
 /** 
  * @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());
         }
     }
 }
Esempio n. 8
0
 /**
  * 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);
     }
 }
Esempio n. 9
0
 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;
     }
 }
Esempio n. 10
0
 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);
     }
 }
Esempio n. 11
0
 public function onMoveEvent(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     foreach ($this->npc as $npc) {
         if ($npc->getLevel()->getFolderName() === $event->getPlayer()->getLevel()->getFolderName()) {
             $npc->seePlayer($player);
         }
     }
 }
Esempio n. 12
0
 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));
     }
 }
 /**
  * @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;
         }
     }
 }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
 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);
     }
 }
Esempio n. 16
0
 public function onMove(PlayerMoveEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     if ($this->checkMove($ev->getTo())) {
         $ev->setCancelled();
     }
     return;
 }
Esempio n. 17
0
 /**
  * Checks if the player is in an arena, and if the game hasn't started yet, stops that player from moving
  * @param PlayerMoveEvent $event
  */
 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $arena = $this->arenaManager->getPlayerArena($event->getPlayer());
     if ($arena != null) {
         // if the player is in an arena
         if (!$arena->inUse) {
             //arena is not in use (match hasn't started)
             $event->setCancelled(true);
         }
     }
 }
Esempio n. 18
0
 /**
  * @priority HIGHEST
  */
 public function onMove(PlayerMoveEvent $e)
 {
     if ($e->isCancelled()) {
         return;
     }
     $pl = $e->getPlayer();
     if (!$this->owner->getState("Torch", $pl, null)) {
         return;
     }
     $this->spawnTorch($pl);
 }
Esempio n. 19
0
 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;
         }
     }
 }
Esempio n. 20
0
 public function onMove(PlayerMoveEvent $event)
 {
     if (isset($this->areas)) {
         $player = $event->getPlayer();
         if (empty($this->areas)) {
             return;
         }
         foreach ($this->areas as $area) {
             if ($this->isInArea($player, $area)) {
                 $this->giveEffect($player, $area);
             }
         }
     }
 }
Esempio n. 21
0
 public function onMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $player->kill();
     $block = $player->getLevel()->getBlock(new Vector3($player->getFloorX(), $player->getFloorY() - 1, $player->getFloorZ()));
     $sender->sendMessage(TextFormat::RED . "Mind the fall!");
     if ($block->getId() === Block::EMERALD_BLOCK) {
         $player->kill();
         if ($this->config->get('use-custom-death-message')) {
             $this->killedByBlock = true;
         }
         // Should call PlayerDeathEvent
     }
 }
Esempio n. 22
0
 public function getTile(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $x = $player->x;
     $y = $player->y - 1;
     $z = $player->z;
     $blockId = $player->getLevel()->getBlockIdAt($x, $y, $z);
     if ($blockId == 7) {
         $this->CritParticle($player);
     }
     if ($blockId == 2) {
         $this->CircleParticle($player);
     }
 }
Esempio n. 23
0
 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"]));
     }
 }
Esempio n. 24
0
 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());
         }
     }
 }
 public function onPlayerMoveEvent(PlayerMoveEvent $event)
 {
     $welt = $event->getPlayer()->getLevel()->getName();
     if ($this->cfg->get("JumpandRunWelt") != $welt) {
         return;
     }
     $name = $event->getPlayer()->getName();
     $player = $event->getPlayer();
     $welt = $event->getPLayer()->getLevel()->getName();
     $block = $event->getPlayer()->getLevel()->getBlock(new Vector3($player->getX(), $player->getY() - 1, $player->getZ()))->getId();
     $coords = round($player->getX()) . ',' . round($player->getY()) . ',' . round($player->getZ());
     $time = time();
     if ($block == 41) {
         $event->getPlayer()->sendTip(MT::GOLD . 'Checkpoint erreicht!');
         $this->coords[$name] = $coords;
     }
     if ($block == 57) {
         $event->getPlayer()->sendTip(MT::GOLD . 'Ziel erreicht!');
         if (!isset($this->zeit)) {
             $this->zeit = time() + 60;
         }
         if (!isset($this->platz1)) {
             $this->platz1 = "{$name}";
             $player->sendMessage(MT::GOLD . "{$name} du bist Erster");
         } else {
             if (!isset($this->platz2)) {
                 if ($name == $this->platz1) {
                     return;
                 }
                 $this->platz2 = "{$name}";
                 $player->sendMessage(MT::GOLD . "{$name} du bist Zweiter");
             } else {
                 if (!isset($this->platz3)) {
                     if ($name == $this->platz1 || $name == $this->platz2) {
                         return;
                     }
                     $this->platz3 = "{$name}";
                     $player->sendMessage(MT::GOLD . "{$name} du bist Dritter");
                 } else {
                     //
                 }
             }
         }
         foreach ($this->getServer()->getOnlinePlayers() as $player) {
             $player->sendMessage(MT::GOLD . "{$name} hat das Ziel erreicht");
         }
     }
     if (isset($this->zeit)) {
         if ($time <= $this->zeit) {
         } else {
         }
     }
     if (!isset($this->start)) {
         $event->setCancelled(true);
     }
 }
Esempio n. 26
0
 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();
         }
     }
 }
Esempio n. 27
0
 public function onVoidLoop(PlayerMoveEvent $event)
 {
     if ($event->getTo()->getFloorY() < 0) {
         $enableConf = $this->getConfig()->get("enableConf");
         $X = $this->getConfig()->get("X");
         $Y = $this->getConfig()->get("Y");
         $Z = $this->getConfig()->get("Z");
         $Level = $this->getConfig()->get("Level");
         $player = $event->getPlayer();
         if ($enableConf === false) {
             $player->teleport($this->getServer()->getDefaultLevel()->getSpawn());
             $player->setHealth($player->getHealth() - $this->getConfig()->get("hearts"));
         } else {
             $player->teleport(new Vector3($X, $Y + 4, $Z, $Level));
             $player->setHealth($player->getHealth() - $this->getConfig()->get("hearts"));
         }
     }
 }
Esempio n. 28
0
 public function onMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $block = $player->getLevel()->getBlock($player->floor()->subtract(0, 1));
     if ($block instanceof Block) {
         $id = $block->getId();
         $x = $block->getX();
         $y = $block->getY();
         $z = $block->getZ();
         if ($this->getConfig()->get("enabled") === "true") {
             if ($id === 86) {
                 $block->getLevel()->setBlock(new Vector3($x, $y, $z), Block::get(91));
             } elseif ($id === 91) {
                 $block->getLevel()->setBlock(new Vector3($x, $y, $z), Block::get(86));
             }
         }
     }
 }
Esempio n. 29
0
 public function onPlayerMove(PlayerMoveEvent $event)
 {
     $p = $event->getPlayer();
     if (!$p->hasPermission("debe.worldinventory.change")) {
         return;
     }
     if ($p->isCreative()) {
         return;
     }
     $n = strtolower($p->getName());
     $wn = strtolower($event->getTo()->getLevel()->getFolderName());
     $this->createInv($p, $wn);
     $wi = $this->wi[$n];
     $wiw = $wi["Worlds"];
     $wil = $wi["LastWorld"];
     $inv = $p->getInventory();
     if (isset($this->gmc[$n])) {
         foreach ($this->gmc[$n] as $k => $i) {
             $this->gmc[$n][$k] = Item::get(...explode(":", $i));
         }
         $inv->setContents($this->gmc[$n]);
         unset($this->gmc[$n]);
         $change = true;
     }
     if ($wil !== $wn) {
         $wiw[$wil] = [];
         if (!isset($wiw[$wn])) {
             $wiw[$wn] = [];
         }
         foreach ($inv->getContents() as $i) {
             if ($i->getID() !== 0 and $i->getCount() > 0) {
                 $wiw[$wil][] = $i->getID() . ":" . $i->getDamage() . ":" . $i->getCount();
             }
         }
         foreach ($wiw[$wn] as $k => $i) {
             $wiw[$wn][$k] = Item::get(...explode(":", $i));
         }
         $inv->setContents($wiw[$wn]);
         $wiw[$wn] = [];
         $this->wi[$n] = ["LastWorld" => $wn, "Worlds" => $wiw];
         $this->saveYml();
         $p->sendMessage("[WorldInventory] " . ($this->isKorean() ? "인벤토리가 교체되었습니다." : "Inventory is change") . " : WorldChange");
     }
 }
Esempio n. 30
0
 /**
  * @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;
             }
         }
     }
 }