geforkt von Mirrors/Paper
BUILDTOOLS-251: Make much of Bukkit locale independent
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
b54985de63
Commit
7f7f1608e8
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
@ -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());
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren