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

problems with level unloading

Comments in 'Plugin Development' started by Creeper_Face, Aug 25, 2015.

  1. Creeper_Face
    Offline

    Creeper_Face Banned

    Joined:
    Aug 25, 2015
    Posts:
    6
    Minecraft User:
    Creeperface001
    hi when i try to unload level so before that i teleport all players to another level and for each player use $player->setLevel($anotherLevel); but server crashes when player quit or sometimes after unload

    so when player quit it is this error:
    Code:
    Fatal error: Call to a member function getName() on null in phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/level/Level.php on line 2731
    
    Call Stack:
        0.0248     383176   1. {main}() C:\Users\Honza\Documents\PocketMine-MP\PocketMine-MP.phar:0
        0.0292     377712   2. require_once('phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php') C:\Users\Honza\Documents\PocketMine-MP\PocketMine-MP.phar:1
        0.7987     520032   3. pocketmine\Server->__construct() phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/PocketMine.php:464
        5.9509   16379856   4. pocketmine\Server->start() phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Server.php:1701
        5.9651   16396160   5. pocketmine\Server->tickProcessor() phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Server.php:2101
      322.3192   70373280   6. pocketmine\Server->tick() phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Server.php:2223
      322.3465   70375328   7. pocketmine\Server->doAutoSave() phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Server.php:2512
      322.3466   70375424   8. pocketmine\Player->save() phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Server.php:2361
      322.3574   70363904   9. pocketmine\level\Level->getName() phar://C:/Users/Honza/Documents/PocketMine-MP/PocketMine-MP.phar/src/pocketmine/Player.php:3107
    
    and if server crashes after unload:

    Code:
    #0 /src/pocketmine/Server(0): pocketmine\Server->crashDump(boolean)
    #1 /src/pocketmine/level/Level(536): pocketmine\level\Level->getName(boolean)
    #2 /src/pocketmine/Server(1037): pocketmine\level\Level->unload(boolean)
    #3 /Bedwars/src/BedWars/Arena/Arena(293): pocketmine\Server->unloadLevel(boolean)
    #4 /Bedwars/src/BedWars/Arena/Arena(249): BedWars\Arena\Arena->stopGame(boolean)
    #5 /Bedwars/src/BedWars/Arena/Arena(164): BedWars\Arena\Arena->checkAlive(boolean)
    #6 /Bedwars/src/BedWars/BedWars(283): BedWars\Arena\Arena->leaveArena(boolean)
    #7 /src/pocketmine/command/PluginCommand(57): BedWars\BedWars->onCommand(boolean)
    #8 /src/pocketmine/command/SimpleCommandMap(195): pocketmine\command\PluginCommand->execute(boolean)
    #9 /src/pocketmine/Server(1938): pocketmine\command\SimpleCommandMap->dispatch(boolean)
    #10 /src/pocketmine/Player(2580): pocketmine\Server->dispatchCommand(boolean)
    #11 /src/pocketmine/network/RakLibInterface(140): pocketmine\Player->handleDataPacket(boolean)
    #12 /src/raklib/server/ServerHandler(90): pocketmine\network\RakLibInterface->handleEncapsulated(boolean)
    #13 /src/pocketmine/network/RakLibInterface(79): raklib\server\ServerHandler->handlePacket(boolean)
    #14 /src/pocketmine/network/Network(150): pocketmine\network\RakLibInterface->process(boolean)
    #15 /src/pocketmine/Server(2471): pocketmine\network\Network->processInterfaces(boolean)
    #16 /src/pocketmine/Server(2223): pocketmine\Server->tick(boolean)
    #17 /src/pocketmine/Server(2101): pocketmine\Server->tickProcessor(boolean)
    #18 /src/pocketmine/Server(1701): pocketmine\Server->start(boolean)
    #19 /src/pocketmine/PocketMine(464): pocketmine\Server->__construct(boolean)
    #20 (1): (boolean)
    #21 (0): {main}(boolean)
    
    
    Last edited: Aug 25, 2015
  2. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    What PocketMine build are you using?
  3. Creeper_Face
    Offline

    Creeper_Face Banned

    Joined:
    Aug 25, 2015
    Posts:
    6
    Minecraft User:
    Creeperface001
    pocketmine 1.6 i think it has not build xD
  4. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    501
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Why don't you use $player->teleport()?
    PHP:
    $pos $level->getSafeSpawn();
    $player->teleport($pos);
  5. Creeper_Face
    Offline

    Creeper_Face Banned

    Joined:
    Aug 25, 2015
    Posts:
    6
    Minecraft User:
    Creeperface001
    i use player->teleport but after that i tried to use player->setLevel() because i think player level is still same after teleport. But still crashes
  6. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Use
    PHP:
    $server $this->getServer();
    $lv $server->getLevelByName("levelname");
    $x 15// You can change it to any number
    $y 20// You can change it to any positive number (so e.g. 35, 78, but no -34 or 0)
    $z 35// You can change it to any number
    if ($lv !== null){
    $player->teleport(new Position($x,$y,$z,$lv));
     }
    Don't forget that $level is level object, not string!!!

    PS: When you load levels, use $server->loadLevel("string");
    When you unload levels, use $server->unloadLevel($lv); where $lv is an object
    Last edited: Sep 14, 2015
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    • Unused local variable $levelname
    • Redundant parentheses around "myworld" on line 2
    • Undefined variable $level; did you mean $lv?
    • You should check $lv/$level not null.
    Minecrafter9203 likes this.

Share This Page

Advertisement