Use Locale.ROOT

This commit is contained in:
Jesse Boyd 2019-07-10 21:01:56 +10:00
parent 4a40c7d99c
commit a98a91e066
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() { private void init() {
if (lookupNames != null) { if (lookupNames != null) {
lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ENGLISH), this); lookupNames.putIfAbsent("FastAsyncWorldEdit".toLowerCase(Locale.ROOT), this);
lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ENGLISH), this); lookupNames.putIfAbsent("WorldEdit".toLowerCase(Locale.ROOT), this);
lookupNames.putIfAbsent("FastAsyncWorldEdit", this); lookupNames.putIfAbsent("FastAsyncWorldEdit", this);
lookupNames.putIfAbsent("WorldEdit", this); lookupNames.putIfAbsent("WorldEdit", this);
rename(); rename();
@ -246,7 +246,7 @@ 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())); 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.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Locale;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
public interface IBukkitAdapter { public interface IBukkitAdapter {
@ -231,7 +233,7 @@ public interface IBukkitAdapter {
*/ */
default GameMode adapt(org.bukkit.GameMode gameMode) { default GameMode adapt(org.bukkit.GameMode gameMode) {
checkNotNull(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 * @return WorldEdit EntityType
*/ */
default EntityType adapt(org.bukkit.entity.EntityType 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) { default org.bukkit.entity.EntityType adapt(EntityType entityType) {
if (!entityType.getId().startsWith("minecraft:")) { if (!entityType.getId().startsWith("minecraft:")) {
throw new IllegalArgumentException("Bukkit only supports vanilla entities"); 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) { 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()) { if (pasteApplication == null || pasteApplication.isEmpty()) {
throw new IllegalArgumentException("paste application cannot be null, nor empty"); 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( throw new IllegalArgumentException(
String.format("Unknown application name: %s", pasteApplication)); String.format("Unknown application name: %s", pasteApplication));
} }

View File

@ -72,7 +72,7 @@ public class ClipboardFormats {
checkNotNull(format); checkNotNull(format);
for (String key : format.getAliases()) { for (String key : format.getAliases()) {
String lowKey = key.toLowerCase(Locale.ENGLISH); String lowKey = key.toLowerCase(Locale.ROOT);
ClipboardFormat old = aliasMap.put(lowKey, format); ClipboardFormat old = aliasMap.put(lowKey, format);
if (old != null) { if (old != null) {
aliasMap.put(lowKey, old); aliasMap.put(lowKey, old);
@ -80,7 +80,7 @@ public class ClipboardFormats {
} }
} }
for (String ext : format.getFileExtensions()) { for (String ext : format.getFileExtensions()) {
String lowExt = ext.toLowerCase(Locale.ENGLISH); String lowExt = ext.toLowerCase(Locale.ROOT);
fileExtensionMap.put(lowExt, format); fileExtensionMap.put(lowExt, format);
} }
registeredFormats.add(format); registeredFormats.add(format);
@ -102,7 +102,7 @@ public class ClipboardFormats {
@Nullable @Nullable
public static ClipboardFormat findByAlias(String alias) { public static ClipboardFormat findByAlias(String alias) {
checkNotNull(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()) { if (pasteApplication == null || pasteApplication.isEmpty()) {
throw new IllegalArgumentException("paste application cannot be null, nor empty"); 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( throw new IllegalArgumentException(
String.format("Unknown application name: %s", pasteApplication)); String.format("Unknown application name: %s", pasteApplication));
} }

View File

@ -41,6 +41,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
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;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -812,7 +813,7 @@ public final class BlockTypes {
for (Field field : oldFields) { for (Field field : oldFields) {
if (field.getType() == int.class) { if (field.getType() == int.class) {
int internalId = field.getInt(null); int internalId = field.getInt(null);
String id = "minecraft:" + field.getName().toLowerCase(); String id = "minecraft:" + field.getName().toLowerCase(Locale.ROOT);
String defaultState = blockMap.remove(id); String defaultState = blockMap.remove(id);
if (defaultState == null) { if (defaultState == null) {
if (internalId != 0) { if (internalId != 0) {
@ -844,7 +845,7 @@ public final class BlockTypes {
// Add to $Registry // Add to $Registry
for (BlockType type : values) { 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()]); states = stateList.toArray(new BlockState[stateList.size()]);
@ -888,7 +889,7 @@ public final class BlockTypes {
*/ */
public static BlockType parse(final String type) throws InputParseException { public static BlockType parse(final String type) throws InputParseException {
final String inputLower = type.toLowerCase(); final String inputLower = type.toLowerCase(Locale.ROOT);
String input = inputLower; String input = inputLower;
if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input; if (!input.split("\\[", 2)[0].contains(":")) input = "minecraft:" + input;