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

Level unload cause crash

Comments in 'Plugin Development' started by Guillaume351, Mar 28, 2015.

  1. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Hello,
    when I try to unload the world game-1 using this :
    Code:
    $worldName = "game-".$gameNumber;
            $level = $this->getServer()->getLevelByName($worldName);
            $this->getServer()->unloadLevel($level);
    It crash the server :
    I already tried to do : $this->getServer()->getLevelByName("game-1");
    The problem does not come from there... Also, you can see that the server console says "Unloading level "game-1", but I'm sure it's the unload line that make everything crash, when I remove it it "work" (I need to unload the map to replace it with a new map and load it again)

    Thank you.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Seems pretty like a PHP bug.
    Guillaume351 likes this.
  3. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    I found where it's from, I didn't give enought details : In fact, when a player dies, it teleport this player to the spawn and then it check how many players remains in the game... If it's only one, it tp the last player to the spawn and unload the world... The problem is that the death event isn't finished, and it needs to get name of the world (in pocketmine, not in my plugin), so I need to have my eventlistener running after pocketmine's event process (I hope you can understand, sorry for my english). Is there a way to set priority of my PlayerDeathEvent to run it after PocketMine run its PlayerDeathEvent ?
  4. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    If unloading it is a problem why not let PocketMine automatically unload it? Unless its for a reset.
  5. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    It's for a reset, an automatic skywars map reload :/
    CrazedMiner likes this.
  6. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    What I would do is not do the unload from the PlayerDeathEvent handler. What I would do is schedule a delayed task that will do the Unload.

    That means, your PlayerDeathEvent fires up (and schedules the unload). The core PlayerDeathEvent fires up and does it stuff... a few ticks later, the delayed task runs and does the unload.
    PEMapModder and Guillaume351 like this.
  7. Guillaume351
    Offline

    Guillaume351 Active Member Plugin Developer

    Joined:
    Oct 11, 2013
    Posts:
    150
    Plugins:
    1
    Minecraft User:
    Guillaume351
    Thank you ! Now time to see how delayed task work :3
  8. EvolSoft
    Offline

    EvolSoft Notable Member Plugin Developer

    Joined:
    Sep 10, 2014
    Posts:
    821
    Plugins:
    15
    Minecraft User:
    Flavius12
    I think this is a PM bug.
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    when i unload a world:

    [CRITICAL] Could not execute task mcg76\game\ctf\tasks\PlayResetTimeout: Argument 1 passed to pocketmine\Server::unloadLevel() must be an instance of pocketmine\level\Level, null given, called in C:\Users\Honza\Documents\PocketMine-MP\plugins\BedwarsPE\src\mcg76\game\ctf\CTFManager.php on line 1304 and defined
    13:14:19 [NOTICE] InvalidArgumentException: "Argument 1 passed to pocketmine\Server::unloadLevel() must be an instance of pocketmine\level\Level, null given, called in C:\Users\Honza\Documents\PocketMine-MP\plugins\BedwarsPE\src\mcg76\game\ctf\CTFManager.php on line 1304 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/Server" at line 1002

    my code:
    PHP:
    $level Server::getInstance ()->getLevelByName ("bw1");
            
    Server::getInstance ()->unloadLevel $leveltrue );

Share This Page

Advertisement