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

Solved Level not loading

Comments in 'Plugin Development' started by xBeastMode, Jan 23, 2016.

  1. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I am trying to use teleport with the constructor Position and also tried $level->getSafeSpawn() but I think the level is not loaded because it teleports to the same level you are on. This happened in different servers I tested and if it doesn't work on multiple servers it might be a pocketmine bug. I also tried $server->getLevelByName("world2")->getName() and it crashes with the error of "Call to a member function getName() on null"

    So anyone know a fix to this or how to load levels better, or is there a better way to teleport to multiples levels?
  2. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    just look at multiword plugin:)
  3. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Like... What?
  4. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    ManyWorlds is a good plugin for teleporting between worlds)))
  5. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    //onEnable 
    $this->getServer()->loadLevel($level);
    //
    $player->teleport(new Position($x,$y$z,$this->getServer()->getLevelByName($level));
    teleport to Default spawn
    PHP:
    $player->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
    Last edited: Jan 24, 2016
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Both don't work, already tried.
    Last edited: Jan 23, 2016
  7. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Try loading level/s on enable.
    PHP:
    public function OnEnable()
    {
    # I suppose it's more than 1 level.
    $to_load = ["Level Name","Level Name 2" /* ... */];
    # You can get the server by folder name, but in this case I'll get it by the level name.
    foreach($to_load /* levels */ as $level){
    $level $this->getServer()->getLevelByName($level);
    $this->getServer()->loadLevel($level);
    }
    # Now all levels inside $to_load are loaded.
    }
  8. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    I've figured out that some levels are corrupted and they won't load so I have to generate new ones.

Share This Page

Advertisement