Issue #371 - implement worldEditor.getWorldVersionInfo()

This commit is contained in:
David Vierra 2017-12-15 18:19:39 -10:00
parent 169309d833
commit 1bd31fbd2c
2 changed files with 26 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import random
import re
import struct
import traceback
import collections
import weakref
import numpy
@ -1107,6 +1108,14 @@ class AnvilWorldAdapter(object):
def deleteMap(self, mapID):
self.selectedRevision.deleteFile(self._getMapPath(mapID))
# --- Metadata ---
def getWorldVersionInfo(self):
versionTag = self.metadata.Version
return VersionInfo('java', versionTag.Id, versionTag.Name, versionTag.Snapshot)
VersionInfo = collections.namedtuple('VersionInfo', 'format id name snapshot')
class AnvilMapData(NBTCompoundRef):
def __init__(self, mapTag, mapID, adapter):

View File

@ -587,6 +587,23 @@ class WorldEditor(object):
"""
return self.adapter.metadata
def getWorldVersionInfo(self):
""" Returns a named tuple indicating the latest version of Minecraft that has played this world.
The named tuple will have the following fields:
format: The string "java" for Java Edition worlds.
id: The Minecraft build number. This is the definitive version number for this world file. Example versions:
184: version 1.9.4
922: version 1.11.2
1457: snapshot 17w50a
name: A human-readable version string. Used only to display the version number in world lists.
snapshot: Boolean. Whether this version is a prerelease.
Note that this only indicates the latest version of the game that has played the world. It is possible that
some chunks have not been touched by this version and have data structures from an older version.
"""
return self.adapter.getWorldVersionInfo()
# --- Maps ---
def listMaps(self):