mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Minor upstream changes
This commit is contained in:
parent
3eb7200ea0
commit
c73fc28847
@ -56,7 +56,6 @@ public class SnapshotUtilCommands {
|
||||
aliases = { "restore", "/restore" },
|
||||
usage = "[snapshot]",
|
||||
desc = "Restore the selection from a snapshot",
|
||||
min = 0,
|
||||
max = 1
|
||||
)
|
||||
@Logging(REGION)
|
||||
@ -112,23 +111,14 @@ public class SnapshotUtilCommands {
|
||||
}
|
||||
}
|
||||
|
||||
ChunkStore chunkStore = null;
|
||||
|
||||
// Load chunk store
|
||||
try {
|
||||
chunkStore = snapshot.getChunkStore();
|
||||
SnapshotRestore restore;
|
||||
try (ChunkStore chunkStore = snapshot.getChunkStore()) {
|
||||
BBC.SNAPSHOT_LOADED.send(player, snapshot.getName());
|
||||
} catch (DataException e) {
|
||||
player.printError(BBC.getPrefix() + "Failed to load snapshot: " + e.getMessage());
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
player.printError(BBC.getPrefix() + "Failed to load snapshot: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Restore snapshot
|
||||
SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region);
|
||||
restore = new SnapshotRestore(chunkStore, editSession, region);
|
||||
//player.print(restore.getChunksAffected() + " chunk(s) will be loaded.");
|
||||
|
||||
restore.restore();
|
||||
@ -137,21 +127,18 @@ public class SnapshotUtilCommands {
|
||||
String error = restore.getLastErrorMessage();
|
||||
if (error != null) {
|
||||
BBC.SNAPSHOT_ERROR_RESTORE.send(player);
|
||||
player.printError(BBC.getPrefix() + "Last error: " + error);
|
||||
player.printError("Last error: " + error);
|
||||
} else {
|
||||
BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(player);
|
||||
}
|
||||
} else {
|
||||
player.print(BBC.getPrefix() + String.format("Restored; %d "
|
||||
player.print(String.format("Restored; %d "
|
||||
+ "missing chunks and %d other errors.",
|
||||
restore.getMissingChunks().size(),
|
||||
restore.getErrorChunks().size()));
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
chunkStore.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
} catch (DataException | IOException e) {
|
||||
player.printError("Failed to load snapshot: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,11 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* The chunk format for Minecraft 1.13 and newer
|
||||
*/
|
||||
@ -160,11 +159,13 @@ public class AnvilChunk13 implements Chunk {
|
||||
* @throws DataException
|
||||
*/
|
||||
private void populateTileEntities() throws DataException {
|
||||
tileEntities = new HashMap<>();
|
||||
if (!rootTag.getValue().containsKey("TileEntities")) {
|
||||
return;
|
||||
}
|
||||
List<Tag> tags = NBTUtils.getChildTag(rootTag.getValue(),
|
||||
"TileEntities", ListTag.class).getValue();
|
||||
|
||||
tileEntities = new HashMap<>();
|
||||
|
||||
for (Tag tag : tags) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new InvalidFormatException("CompoundTag expected in TileEntities");
|
||||
@ -172,33 +173,10 @@ public class AnvilChunk13 implements Chunk {
|
||||
|
||||
CompoundTag t = (CompoundTag) tag;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Tag> entry : t.getValue().entrySet()) {
|
||||
switch (entry.getKey()) {
|
||||
case "x":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
x = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
case "y":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
y = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
case "z":
|
||||
if (entry.getValue() instanceof IntTag) {
|
||||
z = ((IntTag) entry.getValue()).getValue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
Map<String, Tag> values = new HashMap<>(t.getValue());
|
||||
int x = ((IntTag) values.get("x")).getValue();
|
||||
int y = ((IntTag) values.get("y")).getValue();
|
||||
int z = ((IntTag) values.get("z")).getValue();
|
||||
|
||||
BlockVector3 vec = BlockVector3.at(x, y, z);
|
||||
tileEntities.put(vec, values);
|
||||
|
@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
@ -83,7 +84,8 @@ public class Snapshot implements Comparable<Snapshot> {
|
||||
* @throws DataException
|
||||
*/
|
||||
private ChunkStore internalGetChunkStore() throws IOException, DataException {
|
||||
if (file.getName().toLowerCase().endsWith(".zip")) {
|
||||
String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
|
||||
if (lowerCaseFileName.endsWith(".zip")) {
|
||||
try {
|
||||
ChunkStore chunkStore = new TrueZipMcRegionChunkStore(file);
|
||||
|
||||
@ -101,9 +103,9 @@ public class Snapshot implements Comparable<Snapshot> {
|
||||
|
||||
return chunkStore;
|
||||
}
|
||||
} else if (file.getName().toLowerCase().endsWith(".tar.bz2")
|
||||
|| file.getName().toLowerCase().endsWith(".tar.gz")
|
||||
|| file.getName().toLowerCase().endsWith(".tar")) {
|
||||
} else if (lowerCaseFileName.endsWith(".tar.bz2")
|
||||
|| lowerCaseFileName.endsWith(".tar.gz")
|
||||
|| lowerCaseFileName.endsWith(".tar")) {
|
||||
try {
|
||||
ChunkStore chunkStore = new TrueZipMcRegionChunkStore(file);
|
||||
|
||||
@ -133,14 +135,15 @@ public class Snapshot implements Comparable<Snapshot> {
|
||||
*/
|
||||
public boolean containsWorld(String worldname) {
|
||||
try {
|
||||
if (file.getName().toLowerCase().endsWith(".zip")) {
|
||||
String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
|
||||
if (lowerCaseFileName.endsWith(".zip")) {
|
||||
try (ZipFile entry = new ZipFile(file)) {
|
||||
return (entry.getEntry(worldname) != null
|
||||
|| entry.getEntry(worldname + "/level.dat") != null);
|
||||
}
|
||||
} else if (file.getName().toLowerCase().endsWith(".tar.bz2")
|
||||
|| file.getName().toLowerCase().endsWith(".tar.gz")
|
||||
|| file.getName().toLowerCase().endsWith(".tar")) {
|
||||
} else if (lowerCaseFileName.endsWith(".tar.bz2")
|
||||
|| lowerCaseFileName.endsWith(".tar.gz")
|
||||
|| lowerCaseFileName.endsWith(".tar")) {
|
||||
try {
|
||||
de.schlichtherle.util.zip.ZipFile entry = new de.schlichtherle.util.zip.ZipFile(file);
|
||||
|
||||
|
@ -114,6 +114,7 @@ public abstract class ChunkStore implements Closeable {
|
||||
return new OldChunk(world, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user