0

corrected world loading by name to handle renamed worlds

This commit is contained in:
Aaron Griffith
2011-02-23 12:52:21 -05:00
parent 3ce887162b
commit dd01eae9e0
2 changed files with 14 additions and 10 deletions

View File

@@ -392,7 +392,7 @@ def get_save_dir():
return path
def get_worlds():
"Returns {world # : level.dat information}"
"Returns {world # or name : level.dat information}"
ret = {}
save_dir = get_save_dir()
@@ -401,12 +401,14 @@ def get_worlds():
return None
for dir in os.listdir(save_dir):
world_dat = os.path.join(save_dir, dir, "level.dat")
if not os.path.exists(world_dat): continue
info = nbt.load(world_dat)[1]
info['Data']['path'] = os.path.join(save_dir, dir)
if dir.startswith("World") and len(dir) == 6:
world_n = int(dir[-1])
world_dat = os.path.join(save_dir, dir, "level.dat")
if not os.path.exists(world_dat): continue
info = nbt.load(world_dat)[1]
info['Data']['path'] = os.path.join(save_dir, dir)
ret[world_n] = info['Data']
if 'LevelName' in info['Data'].keys():
ret[info['Data']['LevelName']] = info['Data']
return ret