Inheritance: extends EntityEvent, implements pocketmine\event\Cancellable
コード例 #1
0
ファイル: BcTpMgr.php プロジェクト: DWWf/pocketmine-plugins
 /**
  * @priority MONITOR
  */
 public function onTeleport(EntityTeleportEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     $from = $ev->getFrom();
     if (!$from->getLevel()) {
         $from->setLevel($pl->getLevel());
     }
     $to = $ev->getTo();
     if (!$to->getLevel()) {
         $to->setLevel($pl->getLevel());
     }
     if ($from->getLevel()->getName() != $to->getLevel()->getName()) {
         if ($this->world) {
             $this->addFx([$from, $to]);
             $this->owner->getServer()->broadcastMessage(mc::_("%1% teleported to %2%", $pl->getName(), $to->getLevel()->getName()));
         }
         return;
     }
     if (!$this->local) {
         return;
     }
     $dist = $from->distance($to);
     if ($dist > $this->local) {
         $this->addFx([$from, $to]);
         $this->owner->getServer()->broadcastMessage(mc::_("%1% teleported away!", $pl->getName()));
     }
 }
コード例 #2
0
 /**
  * @priority MONITOR
  */
 public function onTeleport(EntityTeleportEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     $from = $ev->getFrom()->getLevel();
     $to = $ev->getTo()->getLevel();
     if (!$from) {
         return;
     }
     if (!$to) {
         return;
     }
     if ($from === $to) {
         return;
     }
     //TODO HACK: removes tile entities that linger whenever
     // to a different world
     $pk = new UpdateBlockPacket();
     foreach ($from->getTiles() as $tile) {
         $pk->records[] = [$tile->x, $tile->z, $tile->y, 0, 0, UpdateBlockPacket::FLAG_NONE];
     }
     if (count($pk->records)) {
         $pl->dataPacket($pk);
     }
 }
コード例 #3
0
 /**
  * @priority HIGHEST
  */
 public function onTeleport(EntityTeleportEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n"; //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     if ($pl->hasPermission("wp.cmd.gm.exempt")) {
         return;
     }
     //echo __METHOD__.",".__LINE__."\n"; //##DEBUG
     $world = $ev->getTo()->getLevel();
     if (!$world) {
         $world = $pl->getLevel();
     }
     $world = $world->getName();
     $gm = $this->owner->getCfg($world, "gamemode", null);
     if ($gm === null) {
         $gm = $this->owner->getServer()->getGamemode();
     }
     if ($pl->getGamemode() == $gm) {
         return;
     }
     $pl->sendMessage(mc::_("Changing gamemode to %1%", MPMU::gamemodeStr($gm)));
     $pl->setGamemode($gm);
 }
コード例 #4
0
ファイル: placebo.php プロジェクト: EmreTr1/rtr
 public function onTeleport(EntityTeleportEvent $event)
 {
     if (!$event->getEntity() instanceof Player) {
         return;
     }
     $this->move[$event->getEntity()->getName()] = null;
 }
コード例 #5
0
ファイル: Main.php プロジェクト: ChiefArtz/SpazzyTp
 public function onTeleport(EntityTeleportEvent $event)
 {
     $entity = $event->getEntity();
     $fizz = new EndermanTeleportSound($entity);
     $particle = new PortalParticle($entity);
     $entity->getLevel()->addSound($fizz);
     $entity->getLevel()->addParticle($particle);
 }
コード例 #6
0
ファイル: EventListener.php プロジェクト: flaxues/BuddyPets
 public function onPlayerTeleport(EntityTeleportEvent $event)
 {
     $player = $event->getEntity();
     if ($player instanceof Player) {
         if (!is_null($event->getTo())) {
             if (!is_null($event->getTo()->getLevel())) {
                 $this->plugin->petOwnerRegister($player, $event->getTo()->getLevel()->getName());
             }
         }
     }
 }
コード例 #7
0
 /**
  * @priority MONITOR
  */
 public function onTeleport(EntityTeleportEvent $ev)
 {
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     $from = $ev->getFrom();
     if (!$from->getLevel()) {
         $from->setLevel($pl->getLevel());
     }
     $to = $ev->getTo();
     if (!$to->getLevel()) {
         $to->setLevel($pl->getLevel());
     }
     if (MPMU::apiVersion("1.12.0")) {
         foreach ([$to, $from] as $pos) {
             for ($i = 0; $i < 20; $i++) {
                 $pos->getLevel()->addParticle(new DustParticle(self::randVector($pos), mt_rand() / mt_getrandmax() * 2, 255, 255, 255));
             }
             $pos->getLevel()->addSound(new FizzSound($pos));
         }
     }
     if ($from->getLevel()->getName() != $to->getLevel()->getName()) {
         if ($this->world) {
             $this->owner->getServer()->broadcastMessage(mc::_("%1% teleported to %2%", $pl->getName(), $to->getLevel()->getName()));
         }
         return;
     }
     if (!$this->local) {
         return;
     }
     $dist = $from->distance($to);
     if ($dist > $this->local) {
         $this->owner->getServer()->broadcastMessage(mc::_("%1% teleported away!", $pl->getName()));
     }
 }
コード例 #8
0
 public function onTeleport(EntityTeleportEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n"; //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $et = $ev->getEntity();
     if (!$et instanceof Player) {
         return;
     }
     $from = $ev->getFrom()->getLevel();
     $to = $ev->getTo()->getLevel();
     if (!$from) {
         // THIS SHOULDN'T HAPPEN!
         return;
     }
     if (!$to) {
         // Somebody did not initialize the level properly!
         // But we return because they do not intent to change worlds
         return;
     }
     $from = $from->getName();
     $to = $to->getName();
     //echo "FROM:$from TO:$to\n";//##DEBUG
     if ($from == $to) {
         return;
     }
     $max = $this->getCfg($to, 0);
     if ($max == 0) {
         return;
     }
     $np = count($this->owner->getServer()->getLevelByName($to)->getPlayers());
     if ($np >= $max) {
         $ev->setCancelled();
         $et->sendMessage(mc::_("Unable to teleport to %1%\nWorld is full", $to));
         $this->owner->getLogger()->notice(mc::_("%1% is FULL", $to));
     }
 }
コード例 #9
0
ファイル: XcelNgien.php プロジェクト: organization/XcelNgien
 public function onPlayerTeleport(EntityTeleportEvent $event)
 {
     $player = $event->getEntity();
     if (!$player instanceof Player) {
         return;
     }
     if (!isset(self::$players[$player->getName()])) {
         return;
     }
     $xcelPlayer = self::$players[$player->getName()];
     if (($fromLevel = $event->getFrom()->getLevel()->getFolderName()) !== ($toLevel = $event->getTo()->getLevel()->getFolderName())) {
         if (isset(self::$worlds[$toLevel])) {
             if (self::$worlds[$toLevel] === $xcelPlayer->getGame()) {
                 return;
             }
             self::$worlds[$toLevel]->warpPlayerTo($xcelPlayer);
         }
         if ($xcelPlayer->getGame() !== null) {
             $xcelPlayer->getGame()->onPlayerMoveToAnotherWorld($xcelPlayer);
         }
         if (isset(self::$worlds[$toLevel])) {
             self::$worlds[$toLevel]->warpPlayerTo($xcelPlayer);
         }
     }
 }
コード例 #10
0
 /**
  * @param EntityTeleportEvent $event
  * @priority MONITOR
  */
 public function mon_onTeleport(EntityTeleportEvent $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof Player and isset($this->sessions[Session::offset($entity)])) {
         $this->sessions[Session::offset($entity)]->mon_onTeleport($event);
     }
 }
コード例 #11
0
ファイル: EconomySell.php プロジェクト: dog194/EconomyS
 public function onPlayerTeleport(EntityTeleportEvent $event)
 {
     $player = $event->getEntity();
     if ($player instanceof Player) {
         if (($from = $event->getFrom()->getLevel()) !== ($to = $event->getTo()->getLevel())) {
             if (isset($this->items[$from->getFolderName()])) {
                 foreach ($this->items[$from->getFolderName()] as $displayer) {
                     $displayer->despawnFrom($player);
                 }
             }
             if (isset($this->items[$to->getFolderName()])) {
                 foreach ($this->items[$to->getFolderName()] as $displayer) {
                     $displayer->spawnTo($player);
                 }
             }
         }
     }
 }
コード例 #12
0
ファイル: Main.php プロジェクト: EmreTr1/GoodGame
 public function onTeleport(EntityTeleportEvent $event)
 {
     $entity = $event->getEntity();
     if ($this->config->get("EntityTeleportEvent", true)) {
         if ($entity instanceof Player) {
             $pos = $event->getFrom();
             $entity->sendPopUp($this->prefix . "§aTeleported: {$pos}");
             $entity->getLevel()->addSound(new PopSound($entity));
         }
     }
 }
コード例 #13
0
ファイル: Entity.php プロジェクト: boybook/PocketMine-MP
 public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
 {
     $from = Position::fromObject($this, $this->getLevel());
     $to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->getLevel());
     $this->server->getPluginManager()->callEvent($ev = new EntityTeleportEvent($this, $from, $to));
     if ($ev->isCancelled()) {
         return false;
     }
     $this->ySize = 0;
     $pos = $ev->getTo();
     $this->setMotion(new Vector3(0, 0, 0));
     if ($this->setPositionAndRotation($pos, $yaw === null ? $this->yaw : $yaw, $pitch === null ? $this->pitch : $pitch, true) !== false) {
         $this->fallDistance = 0;
         $this->onGround = true;
         return true;
     }
     return false;
 }
コード例 #14
0
 /**
  * @priority LOWEST
  */
 public function onPlayerTeleport(EntityTeleportEvent $e)
 {
     $pl = $e->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     $state = $this->getState($pl, null);
     if ($state) {
         $this->deSpawn($pl, $state[1]);
         $this->unsetState($pl);
         $pl->sendMessage(mc::_("Magic carpet lost due to teleport!"));
     }
 }
コード例 #15
0
ファイル: EventListener.php プロジェクト: mwvent/WattzMCPE
 public function onPlayerTeleport(EntityTeleportEvent $event)
 {
     return;
     $player = $event->getEntity();
     if (!$player instanceof Player) {
         return;
     }
     if (is_null($event->getTo()->getLevel()) || is_null($event->getFrom()->getLevel())) {
         return;
     }
     $toworld = $event->getTo()->getLevel()->getName();
     $fromworld = $event->getFrom()->getLevel()->getName();
     if ($toworld == $fromworld) {
         return;
     }
     echo "Player tried to go to world " . $toworld . PHP_EOL;
     $event->setCancelled(true);
 }
コード例 #16
0
ファイル: Main.php プロジェクト: The-Epic-Miner/MinigameBase
 public function onTeleport(EntityTeleportEvent $event)
 {
     if ($event->getEntity() instanceof Player) {
         if ($this->disableTeleport) {
             $event->setCancelled();
         }
     }
     return;
 }
コード例 #17
0
ファイル: Main.php プロジェクト: onebone/NPC
 public function onEntityTeleport(EntityTeleportEvent $event)
 {
     $player = $event->getEntity();
     if ($player instanceof Player) {
         if ($event->getFrom()->getLevel()->getFolderName() !== ($toLevel = $event->getTo()->getLevel()->getFolderName())) {
             foreach ($this->npc as $npc) {
                 if ($npc->getLevel()->getFolderName() === $toLevel) {
                     $npc->spawnTo($player);
                 } else {
                     $npc->removeFrom($player);
                 }
             }
         }
     }
 }
コード例 #18
0
 /**
  * @param EntityTeleportEvent $event
  */
 public function onEntityTeleport(EntityTeleportEvent $event)
 {
     $entity = $event->getEntity();
     if ($entity instanceof Player) {
         $this->getPlugin()->setPlayerLastPosition($entity, $entity->getLocation());
     }
 }
コード例 #19
0
ファイル: EntityListener.php プロジェクト: HerO-0110/Jail
 public function onTeleport(EntityTeleportEvent $event)
 {
     if ($event->getEntity() instanceof Player && $this->plugin->isJailed($event->getEntity())) {
         $event->setCancelled(true);
     }
 }
コード例 #20
0
ファイル: Session.php プロジェクト: LegionPE/LegionPE-Eta
 public function mon_onTeleport(EntityTeleportEvent $event)
 {
     if ($this->disableTpListener or !$this->authenticated) {
         return;
     }
     if ($event->getFrom()->getLevel()->getName() !== $event->getTo()->getLevel()->getName()) {
         $this->tell("After finishing your current job, please go back to hub. You have quitted all games due to world teleportation.");
         $game = $this->main->getGame($this->session);
         if ($game instanceof Game) {
             $game->onQuit($this, true);
             $this->unsubscribeFromChannel($game->getDefaultChatChannel());
         }
         $this->session = self::SESSION_GAME_HUB;
     } else {
         $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);
         }
     }
 }
コード例 #21
0
ファイル: Entity.php プロジェクト: Cybertechpp/Steadfast2
 /**
  * @param Vector3|Position|Location $pos
  * @param float                     $yaw
  * @param float                     $pitch
  *
  * @return bool
  */
 public function teleport(Vector3 $pos, $yaw = \null, $pitch = \null)
 {
     if ($pos instanceof Location) {
         $yaw = $yaw === \null ? $pos->yaw : $yaw;
         $pitch = $pitch === \null ? $pos->pitch : $pitch;
     }
     $from = Position::fromObject($this, $this->level);
     $to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->level);
     $this->server->getPluginManager()->callEvent($ev = new EntityTeleportEvent($this, $from, $to));
     if ($ev->isCancelled()) {
         return \false;
     }
     $this->ySize = 0;
     $pos = $ev->getTo();
     $this->setMotion(new Vector3(0, 0, 0));
     if ($this->setPositionAndRotation($pos, $yaw === \null ? $this->yaw : $yaw, $pitch === \null ? $this->pitch : $pitch, \true) !== \false) {
         $this->resetFallDistance();
         $this->onGround = \true;
         $this->lastX = $this->x;
         $this->lastY = $this->y;
         $this->lastZ = $this->z;
         $this->lastYaw = $this->yaw;
         $this->lastPitch = $this->pitch;
         foreach ($this->hasSpawned as $player) {
             $player->addEntityMovement($this->getId(), $this->x, $this->y + $this->getEyeHeight(), $this->z, $this->yaw, $this->pitch, $this->yaw);
         }
         return \true;
     }
     return \false;
 }
コード例 #22
0
 public function onEntityTeleport(EntityTeleportEvent $event)
 {
     $Player = $event->getEntity();
     $From = $event->getFrom();
     $To = $event->getTo();
     $Level = $Player->getLevel();
     $Level2 = $From->getLevel();
     $Level3 = $To->getLevel();
     if ($Level2->getFolderName() != $Level3->getFolderName() && ($this->plugin->game->level_name == $Level2->getFolderName() || $this->plugin->game->level_name == $Level3->getFolderName())) {
         $event->setCancelled($this->plugin->getState("teleport", $Player, true));
         $this->plugin->setState("teleport", $Player, true);
         return;
     }
     if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName() || $this->plugin->game->status == 0) {
         return;
     }
     if ($Player instanceof Player) {
         if ($Team = $this->plugin->game->getTeamByPlayer($Player)) {
             $event->setCancelled($this->plugin->getState("teleport", $Player, true));
             $this->plugin->setState("teleport", $Player, true);
         }
     }
 }
コード例 #23
0
 public function onTeleport(EntityTeleportEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     $to = clone $ev->getTo();
     if (!$to) {
         return;
     }
     // This should never happen!
     if ($to->getLevel()) {
         $world = $to->getLevel()->getName();
     } else {
         $from = $ev->getFrom();
         if (!$from) {
             return;
         }
         // OK, this would be weird...
         if (!$from->getLevel()) {
             return;
         }
         // Can't determine the level at all!
         $world = $from->getLevel()->getName();
     }
     //echo __METHOD__.",".__LINE__."world=$world\n"; //##DEBUG
     if ($this->checkMove($world, $to->getX(), $to->getZ())) {
         return;
     }
     $this->owner->msg($pl, mc::_("You are teleporting outside the world"));
     $ev->setCancelled();
 }
コード例 #24
0
 /** 
  * @param EntityTeleportEvent $event 
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onEntityTeleport(EntityTeleportEvent $event)
 {
     if (($player = $event->getEntity()) instanceof Player) {
         if (!$this->plugin->getStorage()->getShield($player->getLevel())->isAllowed(Shield::TELEPORTING)) {
             $event->setCancelled(true);
             $player->sendTip($this->plugin->getConfig()->get("teleportNotAllowed"));
         }
     }
 }
コード例 #25
0
 public function onTeleport(EntityTeleportEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     if ($ev->getTo()->getLevel() == null) {
         return;
     }
     $this->owner->getServer()->getScheduler()->scheduleDelayedTask(new PluginCallbackTask($this->owner, [$this, "afterTeleport"], [$pl, $ev->getFrom()->getLevel(), $ev->getTo()->getLevel()]), 10);
 }
コード例 #26
0
ファイル: Main.php プロジェクト: Artide/DynMapPE
 public function onTeleport(EntityTeleportEvent $event)
 {
     if ($event->getEntity() instanceof Player) {
         $request = "UPDATE `dynmap_players` SET `world` = '" . $event->getEntity()->getLevel()->getName() . "' ,`x` = '" . $event->getEntity()->getX() . "',`y` = '" . $event->getEntity()->getY() . "',`z` = '" . $event->getEntity()->getZ() . "' WHERE `name` = '" . $event->getEntity()->getName() . "'";
         if (!($result = $this->database->query($request))) {
             $this->getLogger()->notice('There was an error running the query [' . $this->database->error . ']');
         }
         return;
     }
 }
コード例 #27
0
ファイル: Entity.php プロジェクト: RedstoneAlmeida/Steadfast2
 /**
  * @param Vector3|Position|Location $pos
  * @param float                     $yaw
  * @param float                     $pitch
  *
  * @return bool
  */
 public function teleport(Vector3 $pos, $yaw = null, $pitch = null)
 {
     if ($pos instanceof Location) {
         $yaw = $yaw === null ? $pos->yaw : $yaw;
         $pitch = $pitch === null ? $pos->pitch : $pitch;
     }
     $from = Position::fromObject($this, $this->level);
     $to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->level);
     $this->server->getPluginManager()->callEvent($ev = new EntityTeleportEvent($this, $from, $to));
     if ($ev->isCancelled()) {
         return false;
     }
     $this->ySize = 0;
     $pos = $ev->getTo();
     $this->setMotion(new Vector3(0, 0, 0));
     if ($this->setPositionAndRotation($pos, $yaw === null ? $this->yaw : $yaw, $pitch === null ? $this->pitch : $pitch, true) !== false) {
         $this->resetFallDistance();
         $this->onGround = true;
         $this->lastX = $this->x;
         $this->lastY = $this->y;
         $this->lastZ = $this->z;
         $this->lastYaw = $this->yaw;
         $this->lastPitch = $this->pitch;
         $this->updateMovement();
         return true;
     }
     return false;
 }
コード例 #28
0
 public function onTeleport(EntityTeleportEvent $event)
 {
     $ent = $event->getEntity();
     if (!$ent instanceof Player) {
         return;
     }
     $session = $this->main->getSession($ent);
     if (!$session instanceof Session) {
         $event->setCancelled();
         return;
     }
     if ($session->onTeleport($event) === false) {
         $event->setCancelled();
     }
 }