Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Stuck in rock

Comments in 'Plugin Development' started by Legoboy0215, Jul 6, 2015.

  1. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    When I use this code:
    PHP:
            foreach($this->getServer()->getLevelByName("survival")->getPlayers() as $p) {
                
    $level $this->getServer()->getLevelByName("lobby");
                
    $x $level->getSafeSpawn()->getX();
                
    $y $level->getSafeSpawn()->getY();
                
    $z $level->getSafeSpawn()->getZ();
                
    $p->setLevel($level);
                
    $p->teleport(new Position($x$y$z$level));
               }
    It teleports all players to rock some where in the same world survival. What did I do wrong?
  2. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I don't think you have to set the level.
  3. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Just incase...
  4. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    foreach($this->getServer()->getLevelByName("survival")->getPlayers() as $p) {
    $level $this->getServer()->getLevelByName("lobby");
    if(
    $level instanceof Level){
    $x $level->getSafeSpawn()->getX();
    $y $level->getSafeSpawn()->getY();
    $z $level->getSafeSpawn()->getZ();
    $p->teleport(new Position($x$y$z$level));
    }else{
    // I would add some debug message
    }
     }
    Legoboy0215 likes this.
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You should just
    $p->teleport($level->getSafeSpawn());
    No need to construct another position objec5.
    Legoboy0215 likes this.

Share This Page

Advertisement