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

Reload level

Comments in 'Plugin Development' started by Tarik02, Jul 22, 2015.

  1. Tarik02
    Offline

    Tarik02 New Member

    Joined:
    Jun 24, 2015
    Posts:
    26
    Minecraft User:
    Tarik02
    How to reload level with event or callback. How to hook, when level unloaded, and load it?
  2. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    PHP:
    $this->getServer()->unloadLevel($this->getServer()->getLevelByName("myname"));
    $this->getServer()->loadLevel($this->getServer()->getLevelByName("myname"));
    This is method I use in SW plugin.
  3. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    + Level must be loaded, if level isn't loaded and you try to unload it, server will crash. So I load all levels onLoad()
  4. Tarik02
    Offline

    Tarik02 New Member

    Joined:
    Jun 24, 2015
    Posts:
    26
    Minecraft User:
    Tarik02
    no, level already loaded, i check this before unloading.
  5. Tarik02
    Offline

    Tarik02 New Member

    Joined:
    Jun 24, 2015
    Posts:
    26
    Minecraft User:
    Tarik02
    You try to load level, when it already loaded. Level unloaded dont momently. /:
  6. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I don't know for what you want it. In my SW plugin, I need it for resetting arena maps. And it works.
  7. Tarik02
    Offline

    Tarik02 New Member

    Joined:
    Jun 24, 2015
    Posts:
    26
    Minecraft User:
    Tarik02
    I try this but console writes:
    [08:06:22] [Server thread/CRITICAL]: Could not execute task Tarik02\SkyWars\task\ExecuteTask: Invalid empty level name
    [08:06:22] [Server thread/CRITICAL]: pocketmine\utils\LevelException: "Invalid empty level name" (EXCEPTION) in "/src/pocketmine/Server__32bit" at line 1045
  8. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    Sorry...... don't unload/load level object. Load name. $this->getServer()->loadLevel("name");
    Legoboy0215 and Tarik02 like this.
  9. Tarik02
    Offline

    Tarik02 New Member

    Joined:
    Jun 24, 2015
    Posts:
    26
    Minecraft User:
    Tarik02
    LOL
    PHP:
    $this->getServer()->unloadLevel($this->getServer()->getLevelByName("myname"));
    $this->getServer()->loadLevel("myname");
  10. Kvetinac97
    Offline

    Kvetinac97 Active Member Plugin Developer

    Joined:
    Nov 17, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    Kvetinac97
    I forgot.... REALLLY sorry
  11. Tarik02
    Offline

    Tarik02 New Member

    Joined:
    Jun 24, 2015
    Posts:
    26
    Minecraft User:
    Tarik02
    Thank you!
  12. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    No need to be sorry/\ I took 10 minutes trying to figure it out for my minigame plugin... lol

Share This Page

Advertisement