From b32d46b08ad4bb038422d153980bba7382c96c93 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 10 Jul 2019 21:01:56 +1000 Subject: [PATCH] Use Locale.ROOT --- .../com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 6 +++--- .../sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java | 10 ++++++---- .../main/java/com/boydti/fawe/util/IncendoPaster.java | 2 +- .../extent/clipboard/io/ClipboardFormats.java | 6 +++--- .../com/sk89q/worldedit/util/paste/IncendoPaste.java | 2 +- .../com/sk89q/worldedit/world/block/BlockTypes.java | 7 ++++--- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index c16a52975..ef8d4d5e8 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -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))); } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java index b3e7adc07..6ae11c23a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/IBukkitAdapter.java @@ -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)); } } diff --git a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java index 86a415298..7c9128453 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/util/IncendoPaster.java @@ -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)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java index 375f4c2dc..f37245d6c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/ClipboardFormats.java @@ -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()); } /** diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java index 38c460764..7dd004b66 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/paste/IncendoPaste.java @@ -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)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java index 9d3da7a4d..16dc23295 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockTypes.java @@ -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;