Insert Locale.ROOT into all case change methods

This commit is contained in:
Kenzie Togami
2019-05-01 00:03:37 -07:00
committed by Kenzie Togami
parent b47c70025e
commit 13a8c480e3
26 changed files with 119 additions and 76 deletions

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.world.block;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.registry.state.Property;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;
@ -92,9 +93,11 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> {
if (getStates().isEmpty()) {
return this.getBlockType().getId();
} else {
String properties =
getStates().entrySet().stream().map(entry -> entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase()).collect(Collectors.joining(
","));
String properties = getStates().entrySet().stream()
.map(entry -> entry.getKey().getName()
+ "="
+ entry.getValue().toString().toLowerCase(Locale.ROOT))
.collect(Collectors.joining(","));
return this.getBlockType().getId() + "[" + properties + "]";
}
}

View File

@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.time.ZonedDateTime;
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

@ -32,6 +32,7 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
/**
* A repository contains zero or more snapshots.
@ -208,11 +209,17 @@ public class SnapshotRepository {
return false;
}
return (file.isDirectory() && (new File(file, "level.dat")).exists())
|| (file.isFile() && (file.getName().toLowerCase().endsWith(".zip")
|| file.getName().toLowerCase().endsWith(".tar.bz2")
|| file.getName().toLowerCase().endsWith(".tar.gz")
|| file.getName().toLowerCase().endsWith(".tar")));
if (file.isDirectory() && new File(file, "level.dat").exists()) {
return true;
}
if (file.isFile()) {
String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
return lowerCaseFileName.endsWith(".zip")
|| lowerCaseFileName.endsWith(".tar.bz2")
|| lowerCaseFileName.endsWith(".tar.gz")
|| lowerCaseFileName.endsWith(".tar");
}
return false;
}
/**