Solved Loading worlds from specified directories?

Discussion in 'Plugin Development' started by LudicrousYoshi, Mar 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    LudicrousYoshi

    How do you make world folders into World objects?

    For instance, I want to load a specific world from my plugin's folder instead of from where the craftbukkit jar is. I am also aware that World.java is an interface so I also don't know what class to load the world as...

    Can you just load a world like this?:
    Code:
    File file = new File(location of world folder);
    WorldObjectClass myMap = new WorldObjectClass(file);
    
    or something like this?:
    Code:
    File file = new File(location of world folder);
    WorldObjectClass myMap = (WorldObjectClass) file;
     
  2. Offline

    MCForger

    This is were all world files are stored so I am assuming.
    Code:
    Bukkit.getServer().getWorldContainer();
     
  3. Offline

    LudicrousYoshi

    Yeah that looks right, but what I want to do is be able to get worlds from different folders instead of all from the same one.

    So after searching a lot I think worlds are actually created as a CraftWorld object, but I can't be sure. Still need help!

    If anyone even has a different idea of how to do this that'd be better than nothing! :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  4. Offline

    macguy8

    LudicrousYoshi
    Bukkit.createWorld(new WorldCreator("map/file")); possibly?
     
    LudicrousYoshi likes this.
  5. Offline

    LudicrousYoshi

    Does not work exactly like I want, but it is definitely close!! Doing that makes a new world at that location each time. It also overwrites any world that has that name there so all I have to do is figure out how to prevent that which I'll probably be able to figure out myself. Thank you so much macguy8 :)

    Scratch that! I was just using an invalid world file :p That line of code actually DOES do exactly what I want! :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Offline

    macguy8

    LudicrousYoshi
    Great! Also take a look at the JavaDocs for WorkdCreator, you can do all kinds of fancy stuff that'll help also (Use a special seed (for if its a pre-made map and chunks might be generated off the side, to avoid those ugly lines), custom terrain generator for some things, a nether-type generation, end-type generation, etc. you can also use .copy(World world); if you are using a file that will reset (minigame, possibly). Good luck!
     
    LudicrousYoshi likes this.
  7. Offline

    LudicrousYoshi

    You guessed it! I'm making a mini-game plugin pack, and you literally answered my next question of "now how do I make the map not save?"

    Thanks again!
     
Thread Status:
Not open for further replies.

Share This Page