Use Locale.ROOT

This commit is contained in:
Jesse Boyd 2019-07-10 21:01:56 +10:00
parent 50e649acb8
commit b32d46b08a
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
6 changed files with 18 additions and 15 deletions

View File

@ -140,8 +140,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
private void init() {
if (lookupNames != null) {
lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ENGLISH), this);
lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ENGLISH), this);
lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ROOT), this);
lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ROOT), this);
lookupNames.putIfAbsent("FastAsyncWorldEdit", this);
lookupNames.putIfAbsent("WorldEdit", this);
rename();
@ -246,7 +246,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
String mcid = entityType.getName();
if (mcid != null) {
EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(), new EntityType("minecraft:" + mcid.toLowerCase()));
EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(Locale.ROOT), new EntityType("minecraft:" + mcid.toLowerCase(Locale.ROOT)));
}
}
}

View File

@ -26,6 +26,8 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Locale;
import static com.google.common.base.Preconditions.checkNotNull;
public interface IBukkitAdapter {
@ -231,7 +233,7 @@ public interface IBukkitAdapter {
*/
default GameMode adapt(org.bukkit.GameMode gameMode) {
checkNotNull(gameMode);
return GameModes.get(gameMode.name().toLowerCase());
return GameModes.get(gameMode.name().toLowerCase(Locale.ROOT));
}
/**
@ -241,14 +243,14 @@ public interface IBukkitAdapter {
* @return WorldEdit EntityType
*/
default EntityType adapt(org.bukkit.entity.EntityType entityType) {
return EntityTypes.get(entityType.getName().toLowerCase());
return EntityTypes.get(entityType.getName().toLowerCase(Locale.ROOT));
}
default org.bukkit.entity.EntityType adapt(EntityType entityType) {
if (!entityType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla entities");
}
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase());
return org.bukkit.entity.EntityType.fromName(entityType.getId().substring(10).toLowerCase(Locale.ROOT));
}
/**
@ -371,6 +373,6 @@ public interface IBukkitAdapter {
}
default BiomeType adapt(Biome biome) {
return BiomeTypes.get(biome.name().toLowerCase());
return BiomeTypes.get(biome.name().toLowerCase(Locale.ROOT));
}
}

View File

@ -43,7 +43,7 @@ public final class IncendoPaster {
if (pasteApplication == null || pasteApplication.isEmpty()) {
throw new IllegalArgumentException("paste application cannot be null, nor empty");
}
if (!VALID_APPLICATIONS.contains(pasteApplication.toLowerCase(Locale.ENGLISH))) {
if (!VALID_APPLICATIONS.contains(pasteApplication.toLowerCase(Locale.ROOT))) {
throw new IllegalArgumentException(
String.format("Unknown application name: %s", pasteApplication));
}

View File

@ -72,7 +72,7 @@ public class ClipboardFormats {
checkNotNull(format);
for (String key : format.getAliases()) {
String lowKey = key.toLowerCase(Locale.ENGLISH);
String lowKey = key.toLowerCase(Locale.ROOT);
ClipboardFormat old = aliasMap.put(lowKey, format);
if (old != null) {
aliasMap.put(lowKey, old);
@ -80,7 +80,7 @@ public class ClipboardFormats {
}
}
for (String ext : format.getFileExtensions()) {
String lowExt = ext.toLowerCase(Locale.ENGLISH);
String lowExt = ext.toLowerCase(Locale.ROOT);
fileExtensionMap.put(lowExt, format);
}
registeredFormats.add(format);
@ -102,7 +102,7 @@ public class ClipboardFormats {
@Nullable
public static ClipboardFormat findByAlias(String alias) {
checkNotNull(alias);
return aliasMap.get(alias.toLowerCase(Locale.ENGLISH).trim());
return aliasMap.get(alias.toLowerCase(Locale.ROOT).trim());
}
/**

View File

@ -45,7 +45,7 @@ public final class IncendoPaste implements Paster{
if (pasteApplication == null || pasteApplication.isEmpty()) {
throw new IllegalArgumentException("paste application cannot be null, nor empty");
}
if (!VALID_APPLICATIONS.contains(pasteApplication.toLowerCase(Locale.ENGLISH))) {
if (!VALID_APPLICATIONS.contains(pasteApplication.toLowerCase(Locale.ROOT))) {
throw new IllegalArgumentException(
String.format("Unknown application name: %s", pasteApplication));
}

View File

@ -41,6 +41,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@ -895,7 +896,7 @@ public final class BlockTypes {
for (Field field : oldFields) {
if (field.getType() == int.class) {
int internalId = field.getInt(null);
String id = "minecraft:" + field.getName().toLowerCase();
String id = "minecraft:" + field.getName().toLowerCase(Locale.ROOT);
String defaultState = blockMap.remove(id);
if (defaultState == null) {
if (internalId != 0) {
@ -927,7 +928,7 @@ public final class BlockTypes {
// Add to $Registry
for (BlockType type : values) {
$REGISTRY.put(type.getId().toLowerCase(), type);
$REGISTRY.put(type.getId().toLowerCase(Locale.ROOT), type);
}
states = stateList.toArray(new BlockState[stateList.size()]);
@ -975,7 +976,7 @@ public final class BlockTypes {
*/
public static BlockType parse(final String type) throws InputParseException {
final String inputLower = type.toLowerCase();
final String inputLower = type.toLowerCase(Locale.ROOT);
String input = inputLower;
if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input;