Added detection of McRegion-format worlds for snapshot detection.

This commit is contained in:
sk89q 2011-03-09 23:51:40 -08:00
parent 96e75a4cae
commit 1d68fdd11c
6 changed files with 34 additions and 1 deletions

View File

@ -75,4 +75,11 @@ public Chunk getChunk(Vector2D pos)
public void close() throws IOException {
}
/**
* Returns whether the chunk store is of this type.
*
* @return
*/
public abstract boolean isValid();
}

View File

@ -62,4 +62,9 @@ protected InputStream getInputStream(String f1, String f2, String name)
throw new MissingChunkException();
}
}
@Override
public boolean isValid() {
return true; // Yeah, oh well
}
}

View File

@ -54,4 +54,9 @@ protected InputStream getInputStream(String name) throws IOException,
}
}
@Override
public boolean isValid() {
return new File(path, "region").isDirectory();
}
}

View File

@ -164,4 +164,9 @@ private ZipEntry getEntry(String file) {
public void close() throws IOException {
zip.close();
}
@Override
public boolean isValid() {
return true; // Yeah, oh well
}
}

View File

@ -161,4 +161,9 @@ private ZipEntry getEntry(String file) {
public void close() throws IOException {
zip.close();
}
@Override
public boolean isValid() {
return true; // Yeah, oh well
}
}

View File

@ -73,7 +73,13 @@ public ChunkStore getChunkStore() throws IOException, DataException {
throw new DataException("TrueZIP is required for .tar support");
}
} else {
return new FileLegacyChunkStore(file);
ChunkStore chunkStore = new FileMcRegionChunkStore(file);
if (!chunkStore.isValid()) {
return new FileLegacyChunkStore(file);
}
return chunkStore;
}
}