summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-06-26 19:31:59 +1000
committermd_5 <git@md-5.net>2016-06-26 19:31:59 +1000
commitf0973327a93ed495f86e96a3e32bc5678b66a15d (patch)
tree955d75d570e5ee5c91477615503a5bb99cc4ab77
parentc3a46c9b8db54daf9425d73aa593e494f809bbde (diff)
downloadbukkit-f0973327a93ed495f86e96a3e32bc5678b66a15d.tar
bukkit-f0973327a93ed495f86e96a3e32bc5678b66a15d.tar.gz
bukkit-f0973327a93ed495f86e96a3e32bc5678b66a15d.tar.lz
bukkit-f0973327a93ed495f86e96a3e32bc5678b66a15d.tar.xz
bukkit-f0973327a93ed495f86e96a3e32bc5678b66a15d.zip
BUILDTOOLS-251: Make much of Bukkit locale independent
-rw-r--r--src/main/java/org/bukkit/Art.java4
-rw-r--r--src/main/java/org/bukkit/Material.java2
-rw-r--r--src/main/java/org/bukkit/WorldType.java2
-rw-r--r--src/main/java/org/bukkit/command/SimpleCommandMap.java12
-rw-r--r--src/main/java/org/bukkit/command/defaults/EnchantCommand.java2
-rw-r--r--src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java4
-rw-r--r--src/main/java/org/bukkit/command/defaults/VersionCommand.java6
-rw-r--r--src/main/java/org/bukkit/entity/EntityType.java4
-rw-r--r--src/main/java/org/bukkit/permissions/PermissibleBase.java10
-rw-r--r--src/main/java/org/bukkit/permissions/Permission.java2
-rw-r--r--src/main/java/org/bukkit/permissions/PermissionAttachment.java4
-rw-r--r--src/main/java/org/bukkit/permissions/PermissionDefault.java2
-rw-r--r--src/main/java/org/bukkit/plugin/PluginDescriptionFile.java2
-rw-r--r--src/main/java/org/bukkit/plugin/SimplePluginManager.java14
-rw-r--r--src/main/java/org/bukkit/plugin/java/JavaPlugin.java4
-rw-r--r--src/main/java/org/bukkit/potion/PotionEffectType.java6
-rw-r--r--src/test/java/org/bukkit/MaterialTest.java2
17 files changed, 41 insertions, 41 deletions
diff --git a/src/main/java/org/bukkit/Art.java b/src/main/java/org/bukkit/Art.java
index ba66f163..a5ebae70 100644
--- a/src/main/java/org/bukkit/Art.java
+++ b/src/main/java/org/bukkit/Art.java
@@ -99,13 +99,13 @@ public enum Art {
public static Art getByName(String name) {
Validate.notNull(name, "Name cannot be null");
- return BY_NAME.get(name.toLowerCase().replaceAll("_", ""));
+ return BY_NAME.get(name.toLowerCase(java.util.Locale.ENGLISH).replaceAll("_", ""));
}
static {
for (Art art : values()) {
BY_ID.put(art.id, art);
- BY_NAME.put(art.toString().toLowerCase().replaceAll("_", ""), art);
+ BY_NAME.put(art.toString().toLowerCase(java.util.Locale.ENGLISH).replaceAll("_", ""), art);
}
}
}
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
index f962697e..4f08fa5c 100644
--- a/src/main/java/org/bukkit/Material.java
+++ b/src/main/java/org/bukkit/Material.java
@@ -707,7 +707,7 @@ public enum Material {
} catch (NumberFormatException ex) {}
if (result == null) {
- String filtered = name.toUpperCase();
+ String filtered = name.toUpperCase(java.util.Locale.ENGLISH);
filtered = filtered.replaceAll("\\s+", "_").replaceAll("\\W", "");
result = BY_NAME.get(filtered);
diff --git a/src/main/java/org/bukkit/WorldType.java b/src/main/java/org/bukkit/WorldType.java
index e8178030..6c810799 100644
--- a/src/main/java/org/bukkit/WorldType.java
+++ b/src/main/java/org/bukkit/WorldType.java
@@ -37,7 +37,7 @@ public enum WorldType {
* @return Requested WorldType, or null if not found
*/
public static WorldType getByName(String name) {
- return BY_NAME.get(name.toUpperCase());
+ return BY_NAME.get(name.toUpperCase(java.util.Locale.ENGLISH));
}
static {
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index 7a4111a3..5b0f21e1 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -60,8 +60,8 @@ public class SimpleCommandMap implements CommandMap {
* {@inheritDoc}
*/
public boolean register(String label, String fallbackPrefix, Command command) {
- label = label.toLowerCase().trim();
- fallbackPrefix = fallbackPrefix.toLowerCase().trim();
+ label = label.toLowerCase(java.util.Locale.ENGLISH).trim();
+ fallbackPrefix = fallbackPrefix.toLowerCase(java.util.Locale.ENGLISH).trim();
boolean registered = register(label, command, false, fallbackPrefix);
Iterator<String> iterator = command.getAliases().iterator();
@@ -128,7 +128,7 @@ public class SimpleCommandMap implements CommandMap {
return false;
}
- String sentCommandLabel = args[0].toLowerCase();
+ String sentCommandLabel = args[0].toLowerCase(java.util.Locale.ENGLISH);
Command target = getCommand(sentCommandLabel);
if (target == null) {
@@ -157,7 +157,7 @@ public class SimpleCommandMap implements CommandMap {
}
public Command getCommand(String name) {
- Command target = knownCommands.get(name.toLowerCase());
+ Command target = knownCommands.get(name.toLowerCase(java.util.Locale.ENGLISH));
return target;
}
@@ -252,9 +252,9 @@ public class SimpleCommandMap implements CommandMap {
// We register these as commands so they have absolute priority.
if (targets.size() > 0) {
- knownCommands.put(alias.toLowerCase(), new FormattedCommandAlias(alias.toLowerCase(), targets.toArray(new String[targets.size()])));
+ knownCommands.put(alias.toLowerCase(java.util.Locale.ENGLISH), new FormattedCommandAlias(alias.toLowerCase(java.util.Locale.ENGLISH), targets.toArray(new String[targets.size()])));
} else {
- knownCommands.remove(alias.toLowerCase());
+ knownCommands.remove(alias.toLowerCase(java.util.Locale.ENGLISH));
}
}
}
diff --git a/src/main/java/org/bukkit/command/defaults/EnchantCommand.java b/src/main/java/org/bukkit/command/defaults/EnchantCommand.java
index 5f0b6864..5737a48f 100644
--- a/src/main/java/org/bukkit/command/defaults/EnchantCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/EnchantCommand.java
@@ -54,7 +54,7 @@ public class EnchantCommand extends VanillaCommand {
String itemName = item.getType().toString().replaceAll("_", " ");
itemName = WordUtils.capitalizeFully(itemName);
- Enchantment enchantment = getEnchantment(args[1].toUpperCase());
+ Enchantment enchantment = getEnchantment(args[1].toUpperCase(java.util.Locale.ENGLISH));
if (enchantment == null) {
sender.sendMessage(String.format("Enchantment does not exist: %s", args[1]));
} else {
diff --git a/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java b/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java
index 00197f76..ff7f562b 100644
--- a/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java
@@ -436,7 +436,7 @@ public class ScoreboardCommand extends VanillaCommand {
sender.sendMessage(ChatColor.RED + "No team was found by the name '" + teamName + "'");
return false;
}
- String option = args[3].toLowerCase();
+ String option = args[3].toLowerCase(java.util.Locale.ENGLISH);
if (!option.equals("friendlyfire") && !option.equals("color") && !option.equals("seefriendlyinvisibles")) {
sender.sendMessage(ChatColor.RED + "/scoreboard teams option <team> <friendlyfire|color|seefriendlyinvisibles> <value>");
return false;
@@ -448,7 +448,7 @@ public class ScoreboardCommand extends VanillaCommand {
sender.sendMessage(ChatColor.RED + "Valid values for option " + option + " are: true and false");
}
} else {
- String value = args[4].toLowerCase();
+ String value = args[4].toLowerCase(java.util.Locale.ENGLISH);
if (option.equals("color")) {
ChatColor color = TEAMS_OPTION_COLOR.get(value);
if (color == null) {
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
index b55abdbf..760d58eb 100644
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -64,9 +64,9 @@ public class VersionCommand extends BukkitCommand {
}
boolean found = false;
- pluginName = pluginName.toLowerCase();
+ pluginName = pluginName.toLowerCase(java.util.Locale.ENGLISH);
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
- if (plugin.getName().toLowerCase().contains(pluginName)) {
+ if (plugin.getName().toLowerCase(java.util.Locale.ENGLISH).contains(pluginName)) {
describeToSender(plugin, sender);
found = true;
}
@@ -131,7 +131,7 @@ public class VersionCommand extends BukkitCommand {
if (args.length == 1) {
List<String> completions = new ArrayList<String>();
- String toComplete = args[0].toLowerCase();
+ String toComplete = args[0].toLowerCase(java.util.Locale.ENGLISH);
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (StringUtil.startsWithIgnoreCase(plugin.getName(), toComplete)) {
completions.add(plugin.getName());
diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java
index ec4c2a84..028e1f2e 100644
--- a/src/main/java/org/bukkit/entity/EntityType.java
+++ b/src/main/java/org/bukkit/entity/EntityType.java
@@ -215,7 +215,7 @@ public enum EntityType {
static {
for (EntityType type : values()) {
if (type.name != null) {
- NAME_MAP.put(type.name.toLowerCase(), type);
+ NAME_MAP.put(type.name.toLowerCase(java.util.Locale.ENGLISH), type);
}
if (type.typeId > 0) {
ID_MAP.put(type.typeId, type);
@@ -272,7 +272,7 @@ public enum EntityType {
if (name == null) {
return null;
}
- return NAME_MAP.get(name.toLowerCase());
+ return NAME_MAP.get(name.toLowerCase(java.util.Locale.ENGLISH));
}
/**
diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
index 3b95061a..bc772e5b 100644
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
@@ -50,7 +50,7 @@ public class PermissibleBase implements Permissible {
throw new IllegalArgumentException("Permission name cannot be null");
}
- return permissions.containsKey(name.toLowerCase());
+ return permissions.containsKey(name.toLowerCase(java.util.Locale.ENGLISH));
}
public boolean isPermissionSet(Permission perm) {
@@ -66,7 +66,7 @@ public class PermissibleBase implements Permissible {
throw new IllegalArgumentException("Permission name cannot be null");
}
- String name = inName.toLowerCase();
+ String name = inName.toLowerCase(java.util.Locale.ENGLISH);
if (isPermissionSet(name)) {
return permissions.get(name).getValue();
@@ -86,7 +86,7 @@ public class PermissibleBase implements Permissible {
throw new IllegalArgumentException("Permission cannot be null");
}
- String name = perm.getName().toLowerCase();
+ String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
if (isPermissionSet(name)) {
return permissions.get(name).getValue();
@@ -151,7 +151,7 @@ public class PermissibleBase implements Permissible {
Bukkit.getServer().getPluginManager().subscribeToDefaultPerms(isOp(), parent);
for (Permission perm : defaults) {
- String name = perm.getName().toLowerCase();
+ String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
permissions.put(name, new PermissionAttachmentInfo(parent, name, null, true));
Bukkit.getServer().getPluginManager().subscribeToPermission(name, parent);
calculateChildPermissions(perm.getChildren(), false, null);
@@ -181,7 +181,7 @@ public class PermissibleBase implements Permissible {
for (String name : keys) {
Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
boolean value = children.get(name) ^ invert;
- String lname = name.toLowerCase();
+ String lname = name.toLowerCase(java.util.Locale.ENGLISH);
permissions.put(lname, new PermissionAttachmentInfo(parent, lname, attachment, value));
Bukkit.getServer().getPluginManager().subscribeToPermission(name, parent);
diff --git a/src/main/java/org/bukkit/permissions/Permission.java b/src/main/java/org/bukkit/permissions/Permission.java
index 0184f47c..31a78f3c 100644
--- a/src/main/java/org/bukkit/permissions/Permission.java
+++ b/src/main/java/org/bukkit/permissions/Permission.java
@@ -181,7 +181,7 @@ public class Permission {
*/
public Permission addParent(String name, boolean value) {
PluginManager pm = Bukkit.getServer().getPluginManager();
- String lname = name.toLowerCase();
+ String lname = name.toLowerCase(java.util.Locale.ENGLISH);
Permission perm = pm.getPermission(lname);
diff --git a/src/main/java/org/bukkit/permissions/PermissionAttachment.java b/src/main/java/org/bukkit/permissions/PermissionAttachment.java
index b2a44d51..9849261d 100644
--- a/src/main/java/org/bukkit/permissions/PermissionAttachment.java
+++ b/src/main/java/org/bukkit/permissions/PermissionAttachment.java
@@ -83,7 +83,7 @@ public class PermissionAttachment {
* @param value New value of the permission
*/
public void setPermission(String name, boolean value) {
- permissions.put(name.toLowerCase(), value);
+ permissions.put(name.toLowerCase(java.util.Locale.ENGLISH), value);
permissible.recalculatePermissions();
}
@@ -106,7 +106,7 @@ public class PermissionAttachment {
* @param name Name of the permission to remove
*/
public void unsetPermission(String name) {
- permissions.remove(name.toLowerCase());
+ permissions.remove(name.toLowerCase(java.util.Locale.ENGLISH));
permissible.recalculatePermissions();
}
diff --git a/src/main/java/org/bukkit/permissions/PermissionDefault.java b/src/main/java/org/bukkit/permissions/PermissionDefault.java
index 045e733b..00f08b3b 100644
--- a/src/main/java/org/bukkit/permissions/PermissionDefault.java
+++ b/src/main/java/org/bukkit/permissions/PermissionDefault.java
@@ -48,7 +48,7 @@ public enum PermissionDefault {
* @return Specified value, or null if not found
*/
public static PermissionDefault getByName(String name) {
- return lookup.get(name.toLowerCase().replaceAll("[^a-z!]", ""));
+ return lookup.get(name.toLowerCase(java.util.Locale.ENGLISH).replaceAll("[^a-z!]", ""));
}
@Override
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
index c82928ef..b93569f3 100644
--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
+++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
@@ -974,7 +974,7 @@ public final class PluginDescriptionFile {
if (map.get("load") != null) {
try {
- order = PluginLoadOrder.valueOf(((String) map.get("load")).toUpperCase().replaceAll("\\W", ""));
+ order = PluginLoadOrder.valueOf(((String) map.get("load")).toUpperCase(java.util.Locale.ENGLISH).replaceAll("\\W", ""));
} catch (ClassCastException ex) {
throw new InvalidDescriptionException(ex, "load is of wrong type");
} catch (IllegalArgumentException ex) {
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 5a9e50db..74f6d0d7 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -588,11 +588,11 @@ public final class SimplePluginManager implements PluginManager {
}
public Permission getPermission(String name) {
- return permissions.get(name.toLowerCase());
+ return permissions.get(name.toLowerCase(java.util.Locale.ENGLISH));
}
public void addPermission(Permission perm) {
- String name = perm.getName().toLowerCase();
+ String name = perm.getName().toLowerCase(java.util.Locale.ENGLISH);
if (permissions.containsKey(name)) {
throw new IllegalArgumentException("The permission " + name + " is already defined!");
@@ -611,11 +611,11 @@ public final class SimplePluginManager implements PluginManager {
}
public void removePermission(String name) {
- permissions.remove(name.toLowerCase());
+ permissions.remove(name.toLowerCase(java.util.Locale.ENGLISH));
}
public void recalculatePermissionDefaults(Permission perm) {
- if (perm != null && permissions.containsKey(perm.getName().toLowerCase())) {
+ if (perm != null && permissions.containsKey(perm.getName().toLowerCase(java.util.Locale.ENGLISH))) {
defaultPerms.get(true).remove(perm);
defaultPerms.get(false).remove(perm);
@@ -643,7 +643,7 @@ public final class SimplePluginManager implements PluginManager {
}
public void subscribeToPermission(String permission, Permissible permissible) {
- String name = permission.toLowerCase();
+ String name = permission.toLowerCase(java.util.Locale.ENGLISH);
Map<Permissible, Boolean> map = permSubs.get(name);
if (map == null) {
@@ -655,7 +655,7 @@ public final class SimplePluginManager implements PluginManager {
}
public void unsubscribeFromPermission(String permission, Permissible permissible) {
- String name = permission.toLowerCase();
+ String name = permission.toLowerCase(java.util.Locale.ENGLISH);
Map<Permissible, Boolean> map = permSubs.get(name);
if (map != null) {
@@ -668,7 +668,7 @@ public final class SimplePluginManager implements PluginManager {
}
public Set<Permissible> getPermissionSubscriptions(String permission) {
- String name = permission.toLowerCase();
+ String name = permission.toLowerCase(java.util.Locale.ENGLISH);
Map<Permissible, Boolean> map = permSubs.get(name);
if (map == null) {
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
index adbcd83c..d9757bf8 100644
--- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java
@@ -398,11 +398,11 @@ public abstract class JavaPlugin extends PluginBase {
* @return the plugin command if found, otherwise null
*/
public PluginCommand getCommand(String name) {
- String alias = name.toLowerCase();
+ String alias = name.toLowerCase(java.util.Locale.ENGLISH);
PluginCommand command = getServer().getPluginCommand(alias);
if (command == null || command.getPlugin() != this) {
- command = getServer().getPluginCommand(description.getName().toLowerCase() + ":" + alias);
+ command = getServer().getPluginCommand(description.getName().toLowerCase(java.util.Locale.ENGLISH) + ":" + alias);
}
if (command != null && command.getPlugin() == this) {
diff --git a/src/main/java/org/bukkit/potion/PotionEffectType.java b/src/main/java/org/bukkit/potion/PotionEffectType.java
index c62b168a..27c1f47c 100644
--- a/src/main/java/org/bukkit/potion/PotionEffectType.java
+++ b/src/main/java/org/bukkit/potion/PotionEffectType.java
@@ -249,7 +249,7 @@ public abstract class PotionEffectType {
*/
public static PotionEffectType getByName(String name) {
Validate.notNull(name, "name cannot be null");
- return byName.get(name.toLowerCase());
+ return byName.get(name.toLowerCase(java.util.Locale.ENGLISH));
}
/**
@@ -260,7 +260,7 @@ public abstract class PotionEffectType {
* @param type PotionType to register
*/
public static void registerPotionEffectType(PotionEffectType type) {
- if (byId[type.id] != null || byName.containsKey(type.getName().toLowerCase())) {
+ if (byId[type.id] != null || byName.containsKey(type.getName().toLowerCase(java.util.Locale.ENGLISH))) {
throw new IllegalArgumentException("Cannot set already-set type");
} else if (!acceptingNew) {
throw new IllegalStateException(
@@ -268,7 +268,7 @@ public abstract class PotionEffectType {
}
byId[type.id] = type;
- byName.put(type.getName().toLowerCase(), type);
+ byName.put(type.getName().toLowerCase(java.util.Locale.ENGLISH), type);
}
/**
diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java
index cbca8409..61c68711 100644
--- a/src/test/java/org/bukkit/MaterialTest.java
+++ b/src/test/java/org/bukkit/MaterialTest.java
@@ -78,7 +78,7 @@ public class MaterialTest {
@Test
public void matchMaterialByLowerCaseAndSpaces() {
for (Material material : Material.values()) {
- String name = material.toString().replaceAll("_", " ").toLowerCase();
+ String name = material.toString().replaceAll("_", " ").toLowerCase(java.util.Locale.ENGLISH);
assertThat(Material.matchMaterial(name), is(material));
}
}