3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 02:20:07 +01:00

Fixed snapshots not properly loading .mcr files, made snapshots use fast mode.

Dieser Commit ist enthalten in:
sk89q 2012-07-09 23:55:19 -07:00
Ursprung 0d279e7706
Commit 97380f28de
4 geänderte Dateien mit 10 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -42,7 +42,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
int x = pos.getBlockX(); int x = pos.getBlockX();
int z = pos.getBlockZ(); int z = pos.getBlockZ();
String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mcr"; String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mca";
return filename; return filename;
} }

Datei anzeigen

@ -100,21 +100,13 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
name = folder + "/" + name; name = folder + "/" + name;
} }
} else { } else {
Pattern pattern = Pattern.compile(".*\\.mcr$"); Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
Pattern patternmca = Pattern.compile(".*\\.mca$"); // TODO: does this need a separate class?
// World pattern // World pattern
Pattern worldPattern = Pattern.compile(worldname + "\\$"); Pattern worldPattern = Pattern.compile(worldname + "\\$");
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) { for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = (ZipEntry) e.nextElement(); ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world // Check for world
if (worldPattern.matcher(worldname).matches()) { if (worldPattern.matcher(worldname).matches()) {
// Check for file
// TODO: does this need a separate class?
if (patternmca.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
name = folder + "/" + name.replace("mcr", "mca");
break;
}
// Check for file // Check for file
if (pattern.matcher(testEntry.getName()).matches()) { if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/")); folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));

Datei anzeigen

@ -98,19 +98,12 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
name = folder + "/" + name; name = folder + "/" + name;
} }
} else { } else {
Pattern pattern = Pattern.compile(".*\\.mcr$"); Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
Pattern patternmca = Pattern.compile(".*\\.mca$"); // TODO: does this need a separate class?
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) { for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = (ZipEntry) e.nextElement(); ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world // Check for world
if (testEntry.getName().startsWith(worldname + "/")) { if (testEntry.getName().startsWith(worldname + "/")) {
// TODO: does this need a separate class? if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
if (patternmca.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
name = folder + "/" + name.replace("mcr", "mca");
break;
}
if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/")); folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
name = folder + "/" + name; name = folder + "/" + name;
break; break;

Datei anzeigen

@ -155,6 +155,9 @@ public class SnapshotRestore {
for (Map.Entry<BlockVector2D, ArrayList<Vector>> entry : neededChunks.entrySet()) { for (Map.Entry<BlockVector2D, ArrayList<Vector>> entry : neededChunks.entrySet()) {
BlockVector2D chunkPos = entry.getKey(); BlockVector2D chunkPos = entry.getKey();
Chunk chunk; Chunk chunk;
boolean hasFastMode = editSession.hasFastMode();
editSession.setFastMode(true);
try { try {
chunk = chunkStore.getChunk(chunkPos, editSession.getWorld()); chunk = chunkStore.getChunk(chunkPos, editSession.getWorld());
@ -163,7 +166,7 @@ public class SnapshotRestore {
// Now just copy blocks! // Now just copy blocks!
for (Vector pos : entry.getValue()) { for (Vector pos : entry.getValue()) {
BaseBlock block = chunk.getBlock(pos); BaseBlock block = chunk.getBlock(pos);
editSession.setBlock(pos, block); editSession.rawSetBlock(pos, block);
} }
} catch (MissingChunkException me) { } catch (MissingChunkException me) {
missingChunks.add(chunkPos); missingChunks.add(chunkPos);
@ -176,6 +179,8 @@ public class SnapshotRestore {
} catch (IOException ioe) { } catch (IOException ioe) {
errorChunks.add(chunkPos); errorChunks.add(chunkPos);
lastErrorMessage = ioe.getMessage(); lastErrorMessage = ioe.getMessage();
} finally {
editSession.setFastMode(hasFastMode);
} }
} }
} }