Restore ability to restore old MCRegion files.

This commit is contained in:
wizjany 2019-06-06 10:34:12 -04:00
parent 1b4ea528ea
commit 351fd6771a
4 changed files with 20 additions and 6 deletions

View File

@ -109,7 +109,7 @@ public abstract class ChunkStore implements Closeable {
if (dataVersion == 0) dataVersion = -1;
final Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING);
final int currentDataVersion = platform.getDataVersion();
if (dataVersion < currentDataVersion) {
if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
final DataFixer dataFixer = platform.getDataFixer();
if (dataFixer != null) {
return new AnvilChunk13((CompoundTag) dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag, dataVersion).getValue().get("Level"));

View File

@ -78,7 +78,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
throw new ChunkStoreException("CompoundTag expected for chunk; got " + tag.getClass().getName());
}
return (CompoundTag)tag;
return (CompoundTag) tag;
}
}

View File

@ -115,7 +115,14 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
ZipEntry entry = getEntry(name);
if (entry == null) {
throw new MissingChunkException();
if (name.endsWith(".mca")) { // try old mcr format
entry = getEntry(name.replace(".mca", ".mcr"));
if (entry == null) {
throw new MissingChunkException();
}
} else {
throw new MissingChunkException();
}
}
try {
return zip.getInputStream(entry);
@ -150,7 +157,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
ZipEntry testEntry = e.nextElement();
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) { // TODO: does this need a separate class?
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) {
return true;
}
}

View File

@ -102,7 +102,14 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
ZipEntry entry = getEntry(name);
if (entry == null) {
throw new MissingChunkException();
if (name.endsWith(".mca")) { // try old mcr format
entry = getEntry(name.replace(".mca", ".mcr"));
if (entry == null) {
throw new MissingChunkException();
}
} else {
throw new MissingChunkException();
}
}
try {
return zip.getInputStream(entry);
@ -136,7 +143,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
ZipEntry testEntry = e.nextElement();
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) { // TODO: does this need a separate class?
if (testEntry.getName().matches(".*\\.mcr$") || testEntry.getName().matches(".*\\.mca$")) {
return true;
}
}