geforkt von Mirrors/FastAsyncWorldEdit
Add nether snapshot support
Dieser Commit ist enthalten in:
Ursprung
858f8d3c36
Commit
73a86468fe
@ -44,11 +44,14 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
|
|||||||
@Override
|
@Override
|
||||||
protected InputStream getInputStream(String name) throws IOException,
|
protected InputStream getInputStream(String name) throws IOException,
|
||||||
DataException {
|
DataException {
|
||||||
|
String fileName = "region" + File.separator + name;
|
||||||
String file = "region" + File.separator + name;
|
File file = new File(path, fileName);
|
||||||
|
if (!file.exists()) {
|
||||||
|
file = new File(path, "DIM-1" + File.separator + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new FileInputStream(new File(path, file));
|
return new FileInputStream(file);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new MissingChunkException();
|
throw new MissingChunkException();
|
||||||
}
|
}
|
||||||
@ -56,7 +59,8 @@ public class FileMcRegionChunkStore extends McRegionChunkStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
return new File(path, "region").isDirectory();
|
return new File(path, "region").isDirectory() ||
|
||||||
|
new File(path, "DIM-1" + File.separator + "region").isDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -90,52 +90,34 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected InputStream getInputStream(String name)
|
protected InputStream getInputStream(String name)
|
||||||
throws IOException, DataException {
|
throws IOException, DataException {
|
||||||
String file = "region/" + name;
|
|
||||||
|
|
||||||
// Detect subfolder for the world's files
|
// Detect subfolder for the world's files
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
if (!folder.equals("")) {
|
if (!folder.equals("")) {
|
||||||
file = folder + "/" + file;
|
name = folder + "/" + name;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ZipEntry testEntry = zip.getEntry("level.dat");
|
Pattern pattern = Pattern.compile(".*\\.mcr$");
|
||||||
|
for (Enumeration<? extends ZipEntry> e = zip.entries();
|
||||||
// So, the data is not in the root directory
|
e.hasMoreElements(); ) {
|
||||||
if (testEntry == null) {
|
ZipEntry testEntry = (ZipEntry)e.nextElement();
|
||||||
// Let's try a world/ sub-directory
|
|
||||||
testEntry = getEntry("world/level.dat");
|
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile(".*[\\\\/]level\\.dat$");
|
if (pattern.matcher(testEntry.getName()).matches()) {
|
||||||
|
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
|
||||||
// So not there either...
|
name = folder + "/" + name;
|
||||||
if (testEntry == null) {
|
break;
|
||||||
for (Enumeration<? extends ZipEntry> e = zip.entries();
|
|
||||||
e.hasMoreElements(); ) {
|
|
||||||
|
|
||||||
testEntry = e.nextElement();
|
|
||||||
|
|
||||||
// Whoo, found level.dat!
|
|
||||||
if (pattern.matcher(testEntry.getName()).matches()) {
|
|
||||||
folder = testEntry.getName().replaceAll("level\\.dat$", "");
|
|
||||||
folder = folder.substring(0, folder.length() - 1);
|
|
||||||
file = folder + file;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file = "world/" + file;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipEntry entry = getEntry(file);
|
ZipEntry entry = getEntry(name);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
throw new MissingChunkException();
|
throw new MissingChunkException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return zip.getInputStream(entry);
|
return zip.getInputStream(entry);
|
||||||
} catch (ZipException e) {
|
} catch (ZipException e) {
|
||||||
throw new IOException("Failed to read " + file + " in ZIP");
|
throw new IOException("Failed to read " + name + " in ZIP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,52 +87,34 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
|
|||||||
@Override
|
@Override
|
||||||
protected InputStream getInputStream(String name)
|
protected InputStream getInputStream(String name)
|
||||||
throws IOException, DataException {
|
throws IOException, DataException {
|
||||||
String file = "region/" + name;
|
|
||||||
|
|
||||||
// Detect subfolder for the world's files
|
// Detect subfolder for the world's files
|
||||||
if (folder != null) {
|
if (folder != null) {
|
||||||
if (!folder.equals("")) {
|
if (!folder.equals("")) {
|
||||||
file = folder + "/" + file;
|
name = folder + "/" + name;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ZipEntry testEntry = zip.getEntry("level.dat");
|
Pattern pattern = Pattern.compile(".*\\.mcr$");
|
||||||
|
for (Enumeration<? extends ZipEntry> e = zip.entries();
|
||||||
// So, the data is not in the root directory
|
e.hasMoreElements(); ) {
|
||||||
if (testEntry == null) {
|
ZipEntry testEntry = (ZipEntry)e.nextElement();
|
||||||
// Let's try a world/ sub-directory
|
|
||||||
testEntry = getEntry("world/level.dat");
|
|
||||||
|
|
||||||
Pattern pattern = Pattern.compile(".*[\\\\/]level\\.dat$");
|
if (pattern.matcher(testEntry.getName()).matches()) {
|
||||||
|
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
|
||||||
// So not there either...
|
name = folder + "/" + name;
|
||||||
if (testEntry == null) {
|
break;
|
||||||
for (Enumeration<? extends ZipEntry> e = zip.entries();
|
|
||||||
e.hasMoreElements(); ) {
|
|
||||||
|
|
||||||
testEntry = (ZipEntry)e.nextElement();
|
|
||||||
|
|
||||||
// Whoo, found level.dat!
|
|
||||||
if (pattern.matcher(testEntry.getName()).matches()) {
|
|
||||||
folder = testEntry.getName().replaceAll("level\\.dat$", "");
|
|
||||||
folder = folder.substring(0, folder.length() - 1);
|
|
||||||
file = folder + file;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file = "world/" + file;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipEntry entry = getEntry(file);
|
ZipEntry entry = getEntry(name);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
throw new MissingChunkException();
|
throw new MissingChunkException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
return zip.getInputStream(entry);
|
return zip.getInputStream(entry);
|
||||||
} catch (ZipException e) {
|
} catch (ZipException e) {
|
||||||
throw new IOException("Failed to read " + file + " in ZIP");
|
throw new IOException("Failed to read " + name + " in ZIP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren