Restore usage of pre-Anvil chunks for snapshots.

Dieser Commit ist enthalten in:
Wizjany 2013-01-18 21:16:45 -05:00
Ursprung 0c38365100
Commit 4320e1a201

Datei anzeigen

@ -24,6 +24,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.regex.Pattern;
public class FileMcRegionChunkStore extends McRegionChunkStore { public class FileMcRegionChunkStore extends McRegionChunkStore {
/** /**
@ -44,19 +45,19 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
@Override @Override
protected InputStream getInputStream(String name, String world) throws IOException, protected InputStream getInputStream(String name, String world) throws IOException,
DataException { DataException {
String fileName = "region" + File.separator + name; Pattern ext = Pattern.compile(".*\\.mc[ra]$"); // allow either file extension, both work the same
File file = new File(path, fileName.replace("mcr", "mca")); // TODO: does this need a separate class? File file = null;
if (!file.exists()) { for (File f : new File(path, "region" + File.separator).listFiles()) {
file = new File(path, fileName); String tempName = f.getName().replaceFirst("mcr$", "mca"); // matcher only does one at a time
} if (ext.matcher(f.getName()).matches() && name.equalsIgnoreCase(tempName)) {
if (!file.exists()) { // get full original path now
file = new File(path, "DIM-1" + File.separator + fileName.replace("mcr", "mca")); // TODO: does this need a separate class? file = new File(path + File.separator + "region" + File.separator + f.getName());
} break;
if (!file.exists()) { }
file = new File(path, "DIM-1" + File.separator + fileName);
} }
try { try {
if (file == null) throw new FileNotFoundException();
return new FileInputStream(file); return new FileInputStream(file);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw new MissingChunkException(); throw new MissingChunkException();