Importing non-Sponge worlds

After reading the docs:
https://docs.spongepowered.org/en/server/getting-started/migrating.html#migrating-from-craftbukkit-or-spigot

And this comment on this thread from last year:

I’m happy to say that manually importing non-Sponge worlds seems to work just fine. However, there are some caveats that I noticed. Is there an update on the plan to create a conversion process? I couldn’t find anything on GitHub.

The first time you start up your server with your imported world, while already playable, the ‘level_sponge.dat’ file isn’t written to disk till you shut the server down the first time. This makes sense as world data is saved on shutdown.

However, say you are importing multiple worlds (which in that thread from last year, it seems that ‘starting over’ is quite common), and you want to visit some old worlds. In order for the World API to detect the world, it needs that .dat file in there. So to import all the worlds, I need to start the server on each one and shut it down to generate the UUID and level name data. That’s all fine and good too.

Here’s where I get stuck. Sponge looks in the folder for the default world to find other worlds. If I move these base directories into the default world dir, I would expect Sponge to find it, but it doesn’t. I think that fails because the dimensionId in the .dat file is a duplicate (set to 0 by default). If I edit the NBT directly to an unused dimensionId, it starts to show up in the list of all WorldProperties. (And since NBT editing is something I think that won’t end up in the API, this is something I’d rather not try to do programmatically myself.)

So my question is: could there be a more formal way to import a world folder? Or to be more specific, could Sponge recursively on startup find world data dirs in the default world dir, give them UUIDs if missing or update their dimensionId values so that those worlds will be detected in Sponge? (Should I file this as a GitHub issue?)

My use case is that if I were to start over on my server, I’d love to just dump my previous world folder into a newly created world dir and have them available right away.

2 Likes

From what I know of the implementation, no conversion code has been written to handle data importing from CraftBukkit’s implementations. It’s not a primary focus at this moment but it’s on our todo list.

3 Likes

Thanks @gabizou. I realize any type of world conversion natrually isn’t a priority right now and shouldn’t be a blocker for hitting beta (keep up the amazing work on everything else!). The docs have a useful section on how to convert your old Bukkit world for use in Sponge. As I mentioned in that wall of text up there, I think the dimensionId issue would still be relevant to how I described swapping the world folders around even going from one Sponge world to another. Again, I agree not a priority, but I’m asking less about automatic importing/conversion of a world but about how to resolve conflicting dimensionId values in level_sponge.dat. Is that also on the todo list? Would it be more constructive to make the suggestion in GitHub? I [very tentatively] might be able to take a stab at a PR too.

Any help at getting this resolved would definitely be appreciated. We might have to adjust our documentation to make note of these issues, if a fix is a long way off. The present solutions do seem to be rather ugly work-arounds that we wouldn’t expect the average user to have to deal with.
Thanks for letting us know of the problems!

1 Like

@DsRulesAll

Got a copy of your old World? Zip it up and provide a link to it here as I can get this resolved for you. This is a really odd issue but I’m fairly sure I know where this is happening at.

2 Likes

Do you think my issue is specific to my world? You ought to be able to replicate what I was seeing on any Sponge server.

  1. Create a new world (ex test1) via server.properties
  2. Start the server
  3. Stop the server
  • test1/level_sponge.dat should be created, and dimensionId should be 0
  1. Create a new world (ex test2) via server.properties
  2. Start the server
  3. Stop the server
  • test2/level_sponge.dat should be created, and dimensionId should be 0
  1. Move test1 folder into test2 folder
  2. Start the server (test2 should still be the default level_name)
  3. Use Server’s getAllWorldProperties() to list out what Sponge knows about. test1’s OVERWORLD won’t be listed.

I can upload my world when I get home from the office if you need it.

@Zidane
Here’s a zip of the world I’m trying to import. It’s from CraftBukkit for 1.6.4. I’ve already manually moved the nether and end dimension folders into it as described in the Sponge docs for migrating:

I’m just curious what documentation you found that helped you figure out the file structure for porting multiple world files. I saw that you put your “sub-worlds” folders inside your main world folder. Did you get this idea from looking at the sponge javadocs? Or somewhere else here on sponge forums that says it should actually work that way?

Sorry to barge in, I’m also stuck trying to get my multi-world system ported and am interested in your issue with the dimensions and hope they’ll provide an answer.

A little bit of trial and error. I wrote two very simple commands - 1) to create a world using the WorldBuilder API (copied largely from the Sponge Cookbook) and 2) to list out the worlds (both loaded and unloaded) known to Sponge (using the getAllWorldProperties method on the instance of Server you get from Game).

When making a world via SpongeAPI and listing all worlds, it worked just fine. So I just dug into what it was doing, compared to my Bukkit world, and investigated the differences until I could manually make it work.

Hope that helps.

1 Like

It does, thanks for the tips. I hadn’t gotten as far as isolating things on my own. I was still looking for documented obvious answers. Time to dig in I guess.

If you both (and Zidane) can figure a good way to solve this issue, i’m more than happy to add this to the docs :wink:

We now have a world migrator
From looking at the code it will pull any worlds from the root directory into the world folder and register them
https://github.com/SpongePowered/SpongeCommon/blob/master/src/main/java/org/spongepowered/common/world/WorldMigrator.java

1 Like

@simon816

All it does is move over the files, fix names, and put where files are needed for Bukkit Vanilla Nethers. It doesn’t register the world because I can’t safely do it. I can’t know any characteristics of the world and would be forced to load the world with defaults. At best I can load what I know are Vanilla worlds but any added custom worlds I’m in the dark about (and only because of their foldernames which is a wash to begin with).

This is where a world management plugin could take over by asking the user for those details when loading the world.

1 Like