Minor upstream changes

This commit is contained in:
MattBDev
2019-05-31 11:20:02 -04:00
parent 3eb7200ea0
commit c73fc28847
4 changed files with 28 additions and 59 deletions

View File

@ -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);

View File

@ -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);

View File

@ -114,6 +114,7 @@ public abstract class ChunkStore implements Closeable {
return new OldChunk(world, tag);
}
@Override
public void close() throws IOException {
}