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

@ -26,6 +26,7 @@ import org.bukkit.OfflinePlayer;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -102,8 +103,8 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
} }
} }
userPermissionsCache.put(key.toLowerCase(), permsCache); userPermissionsCache.put(key.toLowerCase(Locale.ROOT), permsCache);
userGroups.put(key.toLowerCase(), new HashSet<>(groups)); userGroups.put(key.toLowerCase(Locale.ROOT), new HashSet<>(groups));
} }
} }
} }
@ -117,7 +118,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
} }
} }
Set<String> perms = userPermissionsCache.get(player.toLowerCase()); Set<String> perms = userPermissionsCache.get(player.toLowerCase(Locale.ROOT));
if (perms == null) { if (perms == null) {
return defaultPermissionsCache.contains(permission) return defaultPermissionsCache.contains(permission)
|| defaultPermissionsCache.contains("*"); || defaultPermissionsCache.contains("*");
@ -134,7 +135,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
@Override @Override
public boolean inGroup(String player, String group) { public boolean inGroup(String player, String group) {
Set<String> groups = userGroups.get(player.toLowerCase()); Set<String> groups = userGroups.get(player.toLowerCase(Locale.ROOT));
if (groups == null) { if (groups == null) {
return false; return false;
} }
@ -144,7 +145,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
@Override @Override
public String[] getGroups(String player) { public String[] getGroups(String player) {
Set<String> groups = userGroups.get(player.toLowerCase()); Set<String> groups = userGroups.get(player.toLowerCase(Locale.ROOT));
if (groups == null) { if (groups == null) {
return new String[0]; return new String[0];
} }

View File

@ -32,6 +32,7 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -159,8 +160,8 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
} }
} }
userPermissionsCache.put(key.toLowerCase(), permsCache); userPermissionsCache.put(key.toLowerCase(Locale.ROOT), permsCache);
userGroups.put(key.toLowerCase(), new HashSet<>(Arrays.asList(groups))); userGroups.put(key.toLowerCase(Locale.ROOT), new HashSet<>(Arrays.asList(groups)));
} }
} }
} catch (IOException e) { } catch (IOException e) {
@ -184,7 +185,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
} }
} }
Set<String> perms = userPermissionsCache.get(player.toLowerCase()); Set<String> perms = userPermissionsCache.get(player.toLowerCase(Locale.ROOT));
if (perms == null) { if (perms == null) {
return defaultPermissionsCache.contains(permission) return defaultPermissionsCache.contains(permission)
|| defaultPermissionsCache.contains("*"); || defaultPermissionsCache.contains("*");
@ -201,13 +202,13 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
@Override @Override
public boolean inGroup(String player, String group) { public boolean inGroup(String player, String group) {
Set<String> groups = userGroups.get(player.toLowerCase()); Set<String> groups = userGroups.get(player.toLowerCase(Locale.ROOT));
return groups != null && groups.contains(group); return groups != null && groups.contains(group);
} }
@Override @Override
public String[] getGroups(String player) { public String[] getGroups(String player) {
Set<String> groups = userGroups.get(player.toLowerCase()); Set<String> groups = userGroups.get(player.toLowerCase(Locale.ROOT));
if (groups == null) { if (groups == null) {
return new String[0]; return new String[0];
} }

View File

@ -53,6 +53,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -278,7 +279,7 @@ public class BukkitAdapter {
if (!itemType.getId().startsWith("minecraft:")) { if (!itemType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft items"); throw new IllegalArgumentException("Bukkit only supports Minecraft items");
} }
return Material.getMaterial(itemType.getId().substring(10).toUpperCase()); return Material.getMaterial(itemType.getId().substring(10).toUpperCase(Locale.ROOT));
} }
/** /**
@ -292,7 +293,7 @@ public class BukkitAdapter {
if (!blockType.getId().startsWith("minecraft:")) { if (!blockType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks"); throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
} }
return Material.getMaterial(blockType.getId().substring(10).toUpperCase()); return Material.getMaterial(blockType.getId().substring(10).toUpperCase(Locale.ROOT));
} }
/** /**
@ -303,7 +304,7 @@ public class BukkitAdapter {
*/ */
public static GameMode adapt(org.bukkit.GameMode gameMode) { public static GameMode adapt(org.bukkit.GameMode gameMode) {
checkNotNull(gameMode); checkNotNull(gameMode);
return GameModes.get(gameMode.name().toLowerCase()); return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
} }
/** /**
@ -313,7 +314,7 @@ public class BukkitAdapter {
* @return WorldEdit BiomeType * @return WorldEdit BiomeType
*/ */
public static BiomeType adapt(Biome biome) { public static BiomeType adapt(Biome biome) {
return BiomeTypes.get(biome.name().toLowerCase()); return BiomeTypes.get(biome.name().toLowerCase(Locale.ROOT));
} }
public static Biome adapt(BiomeType biomeType) { public static Biome adapt(BiomeType biomeType) {
@ -321,7 +322,7 @@ public class BukkitAdapter {
throw new IllegalArgumentException("Bukkit only supports vanilla biomes"); throw new IllegalArgumentException("Bukkit only supports vanilla biomes");
} }
try { try {
return Biome.valueOf(biomeType.getId().substring(10).toUpperCase()); return Biome.valueOf(biomeType.getId().substring(10).toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return null; return null;
} }
@ -334,7 +335,7 @@ public class BukkitAdapter {
* @return WorldEdit EntityType * @return WorldEdit EntityType
*/ */
public static EntityType adapt(org.bukkit.entity.EntityType entityType) { public static EntityType adapt(org.bukkit.entity.EntityType entityType) {
return EntityTypes.get(entityType.getName().toLowerCase()); return EntityTypes.get(entityType.getName().toLowerCase(Locale.ROOT));
} }
public static org.bukkit.entity.EntityType adapt(EntityType entityType) { public static org.bukkit.entity.EntityType adapt(EntityType entityType) {

View File

@ -44,6 +44,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -149,12 +150,12 @@ public class BukkitPlayer extends AbstractPlayerActor {
@Override @Override
public GameMode getGameMode() { public GameMode getGameMode() {
return GameModes.get(player.getGameMode().name().toLowerCase()); return GameModes.get(player.getGameMode().name().toLowerCase(Locale.ROOT));
} }
@Override @Override
public void setGameMode(GameMode gameMode) { public void setGameMode(GameMode gameMode) {
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase())); player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase(Locale.ROOT)));
} }
@Override @Override

View File

@ -66,6 +66,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.logging.Level; import java.util.logging.Level;
@ -133,7 +134,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
public void setupRegistries() { public void setupRegistries() {
// Biome // Biome
for (Biome biome : Biome.values()) { for (Biome biome : Biome.values()) {
BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(), new BiomeType("minecraft:" + biome.name().toLowerCase())); String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
BiomeType.REGISTRY.register("minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName));
} }
// Block & Item // Block & Item
for (Material material : Material.values()) { for (Material material : Material.values()) {
@ -167,7 +169,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) { for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
String mcid = entityType.getName(); String mcid = entityType.getName();
if (mcid != null) { if (mcid != null) {
EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(), new EntityType("minecraft:" + mcid.toLowerCase())); String lowerCaseMcId = mcid.toLowerCase(Locale.ROOT);
EntityType.REGISTRY.register("minecraft:" + lowerCaseMcId, new EntityType("minecraft:" + lowerCaseMcId));
} }
} }
} }

View File

@ -30,6 +30,7 @@ import org.bukkit.plugin.Plugin;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -52,7 +53,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
@Override @Override
public boolean isPermissionSet(String s) { public boolean isPermissionSet(String s) {
return assignedPermissions.containsKey(s.toLowerCase()); return assignedPermissions.containsKey(s.toLowerCase(Locale.ROOT));
} }
@Override @Override
@ -63,7 +64,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
@Override @Override
public boolean hasPermission(String s) { public boolean hasPermission(String s) {
if (isPermissionSet(s)) { if (isPermissionSet(s)) {
return assignedPermissions.get(s.toLowerCase()); return assignedPermissions.get(s.toLowerCase(Locale.ROOT));
} }
return false; return false;
} }
@ -113,11 +114,11 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
} }
public void setPermission(String permission, boolean value) { public void setPermission(String permission, boolean value) {
assignedPermissions.put(permission.toLowerCase(), value); assignedPermissions.put(permission.toLowerCase(Locale.ROOT), value);
} }
public void unsetPermission(String permission) { public void unsetPermission(String permission) {
assignedPermissions.remove(permission.toLowerCase()); assignedPermissions.remove(permission.toLowerCase(Locale.ROOT));
} }
public void clearPermissions() { public void clearPermissions() {

View File

@ -19,6 +19,8 @@
package com.sk89q.jnbt; package com.sk89q.jnbt;
import java.util.Locale;
/** /**
* The {@code TAG_Byte_Array} tag. * The {@code TAG_Byte_Array} tag.
*/ */
@ -45,7 +47,7 @@ public final class ByteArrayTag extends Tag {
public String toString() { public String toString() {
StringBuilder hex = new StringBuilder(); StringBuilder hex = new StringBuilder();
for (byte b : value) { for (byte b : value) {
String hexDigits = Integer.toHexString(b).toUpperCase(); String hexDigits = Integer.toHexString(b).toUpperCase(Locale.ROOT);
if (hexDigits.length() == 1) { if (hexDigits.length() == 1) {
hex.append("0"); hex.append("0");
} }

View File

@ -19,6 +19,8 @@
package com.sk89q.jnbt; package com.sk89q.jnbt;
import java.util.Locale;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
@ -48,7 +50,7 @@ public final class IntArrayTag extends Tag {
public String toString() { public String toString() {
StringBuilder hex = new StringBuilder(); StringBuilder hex = new StringBuilder();
for (int b : value) { for (int b : value) {
String hexDigits = Integer.toHexString(b).toUpperCase(); String hexDigits = Integer.toHexString(b).toUpperCase(Locale.ROOT);
if (hexDigits.length() == 1) { if (hexDigits.length() == 1) {
hex.append("0"); hex.append("0");
} }

View File

@ -19,6 +19,8 @@
package com.sk89q.jnbt; package com.sk89q.jnbt;
import java.util.Locale;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
/** /**
@ -48,7 +50,7 @@ public class LongArrayTag extends Tag {
public String toString() { public String toString() {
StringBuilder hex = new StringBuilder(); StringBuilder hex = new StringBuilder();
for (long b : value) { for (long b : value) {
String hexDigits = Long.toHexString(b).toUpperCase(); String hexDigits = Long.toHexString(b).toUpperCase(Locale.ROOT);
if (hexDigits.length() == 1) { if (hexDigits.length() == 1) {
hex.append("0"); hex.append("0");
} }

View File

@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -254,7 +255,7 @@ public abstract class CommandsManager<T> {
* @return true if the command exists * @return true if the command exists
*/ */
public boolean hasCommand(String command) { public boolean hasCommand(String command) {
return commands.get(null).containsKey(command.toLowerCase()); return commands.get(null).containsKey(command.toLowerCase(Locale.ROOT));
} }
/** /**
@ -434,7 +435,7 @@ public abstract class CommandsManager<T> {
String cmdName = args[level]; String cmdName = args[level];
Map<String, Method> map = commands.get(parent); Map<String, Method> map = commands.get(parent);
Method method = map.get(cmdName.toLowerCase()); Method method = map.get(cmdName.toLowerCase(Locale.ROOT));
if (method == null) { if (method == null) {
if (parent == null) { // Root if (parent == null) { // Root

View File

@ -22,6 +22,7 @@ package com.sk89q.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
/** /**
@ -274,7 +275,7 @@ public final class StringUtil {
} }
public static <T extends Enum<?>> T lookup(Map<String, T> lookup, String name, boolean fuzzy) { public static <T extends Enum<?>> T lookup(Map<String, T> lookup, String name, boolean fuzzy) {
String testName = name.replaceAll("[ _]", "").toLowerCase(); String testName = name.replaceAll("[ _]", "").toLowerCase(Locale.ROOT);
T type = lookup.get(testName); T type = lookup.get(testName);
if (type != null) { if (type != null) {

View File

@ -72,6 +72,7 @@ import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import static com.sk89q.worldedit.event.platform.Interaction.HIT; import static com.sk89q.worldedit.event.platform.Interaction.HIT;
@ -403,7 +404,7 @@ public final class WorldEdit {
* @throws UnknownDirectionException thrown if the direction is not known * @throws UnknownDirectionException thrown if the direction is not known
*/ */
public BlockVector3 getDirection(Player player, String dirStr) throws UnknownDirectionException { public BlockVector3 getDirection(Player player, String dirStr) throws UnknownDirectionException {
dirStr = dirStr.toLowerCase(); dirStr = dirStr.toLowerCase(Locale.ROOT);
final Direction dir = getPlayerDirection(player, dirStr); final Direction dir = getPlayerDirection(player, dirStr);
@ -424,7 +425,7 @@ public final class WorldEdit {
* @throws UnknownDirectionException thrown if the direction is not known * @throws UnknownDirectionException thrown if the direction is not known
*/ */
public BlockVector3 getDiagonalDirection(Player player, String dirStr) throws UnknownDirectionException { public BlockVector3 getDiagonalDirection(Player player, String dirStr) throws UnknownDirectionException {
dirStr = dirStr.toLowerCase(); dirStr = dirStr.toLowerCase(Locale.ROOT);
final Direction dir = getPlayerDirection(player, dirStr); final Direction dir = getPlayerDirection(player, dirStr);

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.blocks;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -84,7 +85,7 @@ public enum ClothColor {
*/ */
@Nullable @Nullable
public static ClothColor lookup(String name) { public static ClothColor lookup(String name) {
return lookup.get(name.toLowerCase()); return lookup.get(name.toLowerCase(Locale.ROOT));
} }
/** /**

View File

@ -49,6 +49,7 @@ import com.sk89q.worldedit.world.block.FuzzyBlockState;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
/** /**
@ -107,7 +108,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
* @return Mapped string * @return Mapped string
*/ */
private String woolMapper(String string) { private String woolMapper(String string) {
switch (string.toLowerCase()) { switch (string.toLowerCase(Locale.ROOT)) {
case "white": case "white":
return BlockTypes.WHITE_WOOL.getId(); return BlockTypes.WHITE_WOOL.getId();
case "black": case "black":
@ -272,7 +273,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
blockStates.putAll(blockInHand.getStates()); blockStates.putAll(blockInHand.getStates());
} else { } else {
// Attempt to lookup a block from ID or name. // Attempt to lookup a block from ID or name.
blockType = BlockTypes.get(typeString.toLowerCase()); blockType = BlockTypes.get(typeString.toLowerCase(Locale.ROOT));
if (blockType == null) { if (blockType == null) {
throw new NoMatchException("Does not match a valid block type: '" + input + "'"); throw new NoMatchException("Does not match a valid block type: '" + input + "'");
@ -323,7 +324,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (blockAndExtraData.length > 1) { if (blockAndExtraData.length > 1) {
String mobName = blockAndExtraData[1]; String mobName = blockAndExtraData[1];
for (MobType mobType : MobType.values()) { for (MobType mobType : MobType.values()) {
if (mobType.getName().toLowerCase().equals(mobName.toLowerCase())) { if (mobType.getName().toLowerCase(Locale.ROOT).equals(mobName.toLowerCase(Locale.ROOT))) {
mobName = mobType.getName(); mobName = mobType.getName();
break; break;
} }

View File

@ -28,6 +28,8 @@ import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper; import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.Locale;
public class DefaultItemParser extends InputParser<BaseItem> { public class DefaultItemParser extends InputParser<BaseItem> {
public DefaultItemParser(WorldEdit worldEdit) { public DefaultItemParser(WorldEdit worldEdit) {
@ -53,7 +55,7 @@ public class DefaultItemParser extends InputParser<BaseItem> {
} }
if (item == null) { if (item == null) {
ItemType type = ItemTypes.get(input.toLowerCase()); ItemType type = ItemTypes.get(input.toLowerCase(Locale.ROOT));
if (type != null) { if (type != null) {
item = new BaseItem(type); item = new BaseItem(type);
} }

View File

@ -28,6 +28,8 @@ import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.session.request.RequestExtent; import com.sk89q.worldedit.session.request.RequestExtent;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import java.util.Locale;
public class BlockCategoryMaskParser extends InputParser<Mask> { public class BlockCategoryMaskParser extends InputParser<Mask> {
public BlockCategoryMaskParser(WorldEdit worldEdit) { public BlockCategoryMaskParser(WorldEdit worldEdit) {
@ -41,7 +43,7 @@ public class BlockCategoryMaskParser extends InputParser<Mask> {
} }
// This means it's a tag mask. // This means it's a tag mask.
BlockCategory category = BlockCategory.REGISTRY.get(input.substring(2).toLowerCase()); BlockCategory category = BlockCategory.REGISTRY.get(input.substring(2).toLowerCase(Locale.ROOT));
if (category == null) { if (category == null) {
throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\''); throw new InputParseException("Unrecognised tag '" + input.substring(2) + '\'');
} else { } else {

View File

@ -30,6 +30,7 @@ import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -49,7 +50,7 @@ public class BlockCategoryPatternParser extends InputParser<Pattern> {
if (!input.startsWith("##")) { if (!input.startsWith("##")) {
return null; return null;
} }
String tag = input.substring(2).toLowerCase(); String tag = input.substring(2).toLowerCase(Locale.ROOT);
boolean anyState = false; boolean anyState = false;
if (tag.startsWith("*")) { if (tag.startsWith("*")) {
tag = tag.substring(1); tag = tag.substring(1);

View File

@ -123,6 +123,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.logging.FileHandler; import java.util.logging.FileHandler;
@ -425,7 +426,7 @@ public final class PlatformCommandManager {
split = newSplit; split = newSplit;
} }
String searchCmd = split[0].toLowerCase(); String searchCmd = split[0].toLowerCase(Locale.ROOT);
// Try to detect the command // Try to detect the command
if (!commandManager.containsCommand(searchCmd)) { if (!commandManager.containsCommand(searchCmd)) {

View File

@ -56,6 +56,7 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -261,7 +262,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation")); Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation"));
if (!id.isEmpty()) { if (!id.isEmpty()) {
EntityType entityType = EntityTypes.get(id.toLowerCase()); EntityType entityType = EntityTypes.get(id.toLowerCase(Locale.ROOT));
if (entityType != null) { if (entityType != null) {
for (EntityNBTCompatibilityHandler compatibilityHandler : ENTITY_COMPATIBILITY_HANDLERS) { for (EntityNBTCompatibilityHandler compatibilityHandler : ENTITY_COMPATIBILITY_HANDLERS) {
if (compatibilityHandler.isAffectedEntity(entityType, compound)) { if (compatibilityHandler.isAffectedEntity(entityType, compound)) {
@ -271,7 +272,7 @@ public class MCEditSchematicReader extends NBTSchematicReader {
BaseEntity state = new BaseEntity(entityType, compound); BaseEntity state = new BaseEntity(entityType, compound);
clipboard.createEntity(location, state); clipboard.createEntity(location, state);
} else { } else {
log.warn("Unknown entity when pasting schematic: " + id.toLowerCase()); log.warn("Unknown entity when pasting schematic: " + id.toLowerCase(Locale.ROOT));
} }
} }
} }

View File

@ -26,6 +26,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -44,14 +45,14 @@ public class Registry<V> implements Iterable<V> {
} }
public @Nullable V get(final String key) { public @Nullable V get(final String key) {
checkState(key.equals(key.toLowerCase()), "key must be lowercase"); checkState(key.equals(key.toLowerCase(Locale.ROOT)), "key must be lowercase");
return this.map.get(key); return this.map.get(key);
} }
public V register(final String key, final V value) { public V register(final String key, final V value) {
requireNonNull(key, "key"); requireNonNull(key, "key");
requireNonNull(value, "value"); requireNonNull(value, "value");
checkState(key.equals(key.toLowerCase()), "key must be lowercase"); checkState(key.equals(key.toLowerCase(Locale.ROOT)), "key must be lowercase");
checkState(!this.map.containsKey(key), "key '%s' already has an associated %s", key, this.name); checkState(!this.map.containsKey(key), "key '%s' already has an associated %s", key, this.name);
this.map.put(key, value); this.map.put(key, value);
return value; return value;

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.registry.state;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import java.util.List; import java.util.List;
import java.util.Locale;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -34,7 +35,7 @@ public class DirectionalProperty extends AbstractProperty<Direction> {
@Nullable @Nullable
@Override @Override
public Direction getValueFor(final String string) { public Direction getValueFor(final String string) {
Direction direction = Direction.valueOf(string.toUpperCase()); Direction direction = Direction.valueOf(string.toUpperCase(Locale.ROOT));
if (!getValues().contains(direction)) { if (!getValues().contains(direction)) {
throw new IllegalArgumentException("Invalid direction value: " + string + ". Must be in " + getValues().toString()); throw new IllegalArgumentException("Invalid direction value: " + string + ". Must be in " + getValues().toString());
} }

View File

@ -31,6 +31,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
@ -161,7 +162,7 @@ public class TreeGenerator {
*/ */
@Nullable @Nullable
public static TreeType lookup(String name) { public static TreeType lookup(String name) {
return lookup.get(name.toLowerCase()); return lookup.get(name.toLowerCase(Locale.ROOT));
} }
} }

View File

@ -23,6 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function; import com.google.common.base.Function;
import java.util.Locale;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -60,7 +61,7 @@ public class LevenshteinDistance implements Function<String, Integer> {
checkNotNull(baseString); checkNotNull(baseString);
this.caseSensitive = caseSensitive; this.caseSensitive = caseSensitive;
this.replacePattern = replacePattern; this.replacePattern = replacePattern;
baseString = caseSensitive ? baseString : baseString.toLowerCase(); baseString = caseSensitive ? baseString : baseString.toLowerCase(Locale.ROOT);
baseString = replacePattern != null ? replacePattern.matcher(baseString).replaceAll("") : baseString; baseString = replacePattern != null ? replacePattern.matcher(baseString).replaceAll("") : baseString;
this.baseString = baseString; this.baseString = baseString;
} }
@ -79,7 +80,7 @@ public class LevenshteinDistance implements Function<String, Integer> {
if (caseSensitive) { if (caseSensitive) {
return distance(baseString, input); return distance(baseString, input);
} else { } else {
return distance(baseString, input.toLowerCase()); return distance(baseString, input.toLowerCase(Locale.ROOT));
} }
} }

View File

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

View File

@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.Locale;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
/** /**
@ -83,7 +84,8 @@ public class Snapshot implements Comparable<Snapshot> {
* @throws DataException * @throws DataException
*/ */
private ChunkStore internalGetChunkStore() throws IOException, 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 { try {
ChunkStore chunkStore = new TrueZipMcRegionChunkStore(file); ChunkStore chunkStore = new TrueZipMcRegionChunkStore(file);
@ -101,9 +103,9 @@ public class Snapshot implements Comparable<Snapshot> {
return chunkStore; return chunkStore;
} }
} else if (file.getName().toLowerCase().endsWith(".tar.bz2") } else if (lowerCaseFileName.endsWith(".tar.bz2")
|| file.getName().toLowerCase().endsWith(".tar.gz") || lowerCaseFileName.endsWith(".tar.gz")
|| file.getName().toLowerCase().endsWith(".tar")) { || lowerCaseFileName.endsWith(".tar")) {
try { try {
ChunkStore chunkStore = new TrueZipMcRegionChunkStore(file); ChunkStore chunkStore = new TrueZipMcRegionChunkStore(file);
@ -133,14 +135,15 @@ public class Snapshot implements Comparable<Snapshot> {
*/ */
public boolean containsWorld(String worldname) { public boolean containsWorld(String worldname) {
try { try {
if (file.getName().toLowerCase().endsWith(".zip")) { String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
if (lowerCaseFileName.endsWith(".zip")) {
try (ZipFile entry = new ZipFile(file)) { try (ZipFile entry = new ZipFile(file)) {
return (entry.getEntry(worldname) != null return (entry.getEntry(worldname) != null
|| entry.getEntry(worldname + "/level.dat") != null); || entry.getEntry(worldname + "/level.dat") != null);
} }
} else if (file.getName().toLowerCase().endsWith(".tar.bz2") } else if (lowerCaseFileName.endsWith(".tar.bz2")
|| file.getName().toLowerCase().endsWith(".tar.gz") || lowerCaseFileName.endsWith(".tar.gz")
|| file.getName().toLowerCase().endsWith(".tar")) { || lowerCaseFileName.endsWith(".tar")) {
try { try {
de.schlichtherle.util.zip.ZipFile entry = new de.schlichtherle.util.zip.ZipFile(file); 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.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
/** /**
* A repository contains zero or more snapshots. * A repository contains zero or more snapshots.
@ -208,11 +209,17 @@ public class SnapshotRepository {
return false; return false;
} }
return (file.isDirectory() && (new File(file, "level.dat")).exists()) if (file.isDirectory() && new File(file, "level.dat").exists()) {
|| (file.isFile() && (file.getName().toLowerCase().endsWith(".zip") return true;
|| file.getName().toLowerCase().endsWith(".tar.bz2") }
|| file.getName().toLowerCase().endsWith(".tar.gz") if (file.isFile()) {
|| file.getName().toLowerCase().endsWith(".tar"))); String lowerCaseFileName = file.getName().toLowerCase(Locale.ROOT);
return lowerCaseFileName.endsWith(".zip")
|| lowerCaseFileName.endsWith(".tar.bz2")
|| lowerCaseFileName.endsWith(".tar.gz")
|| lowerCaseFileName.endsWith(".tar");
}
return false;
} }
/** /**