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

how to reload a level

Comments in 'Plugin Development' started by Yoyo95220, Sep 30, 2015.

  1. Yoyo95220
    Offline

    Yoyo95220 New Member

    Joined:
    Sep 2, 2015
    Posts:
    8
    Minecraft User:
    Yoyo95220
    I am making a minigame plugin and I would to know how to reload a level
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    PHP:
    if($this->getServer()->isLevelLoaded(/*LevelName*/)){
    $this->getServer()->unloadLevel(/*levelname*/);
    }
    if(!
    $this->getServer()->isLevelLoaded(/*LevelName*/)){
    $this->getServer()->loadLevel(/*LevelName*/);
    }
    SeifValkierks and HotFireyDeath like this.
  3. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    i think this is better :p
    PHP:
    $this->getServer()->unloadLevel(/*levelname*/);
    $this->getServer()->loadLevel(/*LevelName*/);
    because isLevelLodaded() method is impleented in unload/loadLevel too
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    unloadLevel accepts a Level object.
    SeifValkierks and Creeperface like this.
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    This will just make an infinite loop of the level reloading.
  6. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    How? Do you even know how infinite loops work and run? Please don't post if you don't know what you're talking about. It is always good to check if a level is loaded before unloading it, and vice versa.
  7. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    The code checks if the level is loaded, if true it unloads the level. It then checks to see if the level is unloaded, if true it will load the level. So that means that each time the level is loaded, it will be unloaded, and when it is unloaded it will be loaded again. Causing an infinite loop of reloading.
  8. HotFireyDeath
    Offline

    HotFireyDeath Notable Member Plugin Developer

    Joined:
    Mar 19, 2015
    Posts:
    328
    Plugins:
    1
    Minecraft User:
    HotFireyDeath
    Incorrect.
    It will bypass the secondary if() statement after loading/unloading the level.
    Code doesn't rewind unless you tell it to.
  9. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    And you can't check if is loaded because loadLevel() method checks it too

Share This Page

Advertisement