Don't set default locale, instead use Locale.ENGLISH where possible

This commit is contained in:
libraryaddict 2020-09-14 15:01:05 +12:00
parent 4ff00ee828
commit c295011015
27 changed files with 86 additions and 77 deletions

View File

@ -692,14 +692,14 @@ public class DisguiseConfig {
} }
try { try {
setPlayerNameType(PlayerNameType.valueOf(config.getString("PlayerNames").toUpperCase())); setPlayerNameType(PlayerNameType.valueOf(config.getString("PlayerNames").toUpperCase(Locale.ENGLISH)));
} catch (Exception ex) { } catch (Exception ex) {
DisguiseUtilities.getLogger().warning( DisguiseUtilities.getLogger().warning(
"Cannot parse '" + config.getString("PlayerNames") + "' to a valid option for PlayerNames"); "Cannot parse '" + config.getString("PlayerNames") + "' to a valid option for PlayerNames");
} }
try { try {
setNotifyBar(NotifyBar.valueOf(config.getString("NotifyBar").toUpperCase())); setNotifyBar(NotifyBar.valueOf(config.getString("NotifyBar").toUpperCase(Locale.ENGLISH)));
if (getNotifyBar() == NotifyBar.BOSS_BAR && !NmsVersion.v1_13.isSupported()) { if (getNotifyBar() == NotifyBar.BOSS_BAR && !NmsVersion.v1_13.isSupported()) {
DisguiseUtilities.getLogger().warning( DisguiseUtilities.getLogger().warning(
@ -714,21 +714,21 @@ public class DisguiseConfig {
} }
try { try {
setBossBarColor(BarColor.valueOf(config.getString("BossBarColor").toUpperCase())); setBossBarColor(BarColor.valueOf(config.getString("BossBarColor").toUpperCase(Locale.ENGLISH)));
} catch (Exception ex) { } catch (Exception ex) {
DisguiseUtilities.getLogger().warning( DisguiseUtilities.getLogger().warning(
"Cannot parse '" + config.getString("BossBarColor") + "' to a valid option for BossBarColor"); "Cannot parse '" + config.getString("BossBarColor") + "' to a valid option for BossBarColor");
} }
try { try {
setBossBarStyle(BarStyle.valueOf(config.getString("BossBarStyle").toUpperCase())); setBossBarStyle(BarStyle.valueOf(config.getString("BossBarStyle").toUpperCase(Locale.ENGLISH)));
} catch (Exception ex) { } catch (Exception ex) {
DisguiseUtilities.getLogger().warning( DisguiseUtilities.getLogger().warning(
"Cannot parse '" + config.getString("BossBarStyle") + "' to a valid option for BossBarStyle"); "Cannot parse '" + config.getString("BossBarStyle") + "' to a valid option for BossBarStyle");
} }
try { try {
setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase())); setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase(Locale.ENGLISH)));
} catch (Exception ex) { } catch (Exception ex) {
DisguiseUtilities.getLogger().warning( DisguiseUtilities.getLogger().warning(
"Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch"); "Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch");
@ -736,7 +736,7 @@ public class DisguiseConfig {
try { try {
String option = String option =
config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name()).toUpperCase(); config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name()).toUpperCase(Locale.ENGLISH);
if (!option.endsWith("_SCOREBOARD")) { if (!option.endsWith("_SCOREBOARD")) {
option += "_SCOREBOARD"; option += "_SCOREBOARD";

View File

@ -194,12 +194,12 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
return list; return list;
Iterator<String> itel = list.iterator(); Iterator<String> itel = list.iterator();
String label = origArgs[origArgs.length - 1].toLowerCase(); String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
while (itel.hasNext()) { while (itel.hasNext()) {
String name = itel.next(); String name = itel.next();
if (name.toLowerCase().startsWith(label)) if (name.toLowerCase(Locale.ENGLISH).startsWith(label))
continue; continue;
itel.remove(); itel.remove();

View File

@ -14,6 +14,7 @@ import org.bukkit.command.TabCompleter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale;
public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
@Getter @Getter
@ -41,12 +42,12 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
return list; return list;
Iterator<String> itel = list.iterator(); Iterator<String> itel = list.iterator();
String label = origArgs[origArgs.length - 1].toLowerCase(); String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
while (itel.hasNext()) { while (itel.hasNext()) {
String name = itel.next(); String name = itel.next();
if (name.toLowerCase().startsWith(label)) if (name.toLowerCase(Locale.ENGLISH).startsWith(label))
continue; continue;
itel.remove(); itel.remove();
@ -104,7 +105,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
LDCommand command = null; LDCommand command = null;
for (LDCommand c : getCommands()) { for (LDCommand c : getCommands()) {
if (!c.getTabComplete().contains(args[0].toLowerCase())) { if (!c.getTabComplete().contains(args[0].toLowerCase(Locale.ENGLISH))) {
continue; continue;
} }

View File

@ -26,6 +26,7 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter { public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
private int maxRadius = 30; private int maxRadius = 30;
@ -98,7 +99,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
if (starting == 0) { if (starting == 0) {
try { try {
type = EntityType.valueOf(args[0].toUpperCase()); type = EntityType.valueOf(args[0].toUpperCase(Locale.ENGLISH));
} }
catch (Exception ignored) { catch (Exception ignored) {
} }

View File

@ -13,10 +13,7 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter { public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) { protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
@ -24,12 +21,12 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
return list; return list;
Iterator<String> itel = list.iterator(); Iterator<String> itel = list.iterator();
String label = origArgs[origArgs.length - 1].toLowerCase(); String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
while (itel.hasNext()) { while (itel.hasNext()) {
String name = itel.next(); String name = itel.next();
if (name.toLowerCase().startsWith(label)) if (name.toLowerCase(Locale.ENGLISH).startsWith(label))
continue; continue;
itel.remove(); itel.remove();

View File

@ -18,6 +18,7 @@ import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter { public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter {
@ -80,7 +81,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
try { try {
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) { for (Method method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) { if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase()))) { if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(
Locale.ENGLISH)))) {
ignored++; ignored++;
continue; continue;
} }

View File

@ -8,6 +8,8 @@ import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import java.util.Locale;
public enum DisguiseType { public enum DisguiseType {
AREA_EFFECT_CLOUD(3, 0), AREA_EFFECT_CLOUD(3, 0),
@ -364,7 +366,7 @@ public enum DisguiseType {
String[] split = name().split("_"); String[] split = name().split("_");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); split[i] = split[i].charAt(0) + split[i].substring(1).toLowerCase(Locale.ENGLISH);
} }
return TranslateType.DISGUISES.get(StringUtils.join(split, " ")); return TranslateType.DISGUISES.get(StringUtils.join(split, " "));

View File

@ -855,7 +855,7 @@ public class MetaIndex<Y> {
} }
public static MetaIndex getMetaIndexByName(String name) { public static MetaIndex getMetaIndexByName(String name) {
name = name.toUpperCase(); name = name.toUpperCase(Locale.ENGLISH);
try { try {
for (Field field : MetaIndex.class.getFields()) { for (Field field : MetaIndex.class.getFields()) {

View File

@ -6,6 +6,8 @@ import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
import me.libraryaddict.disguise.utilities.reflection.NmsVersion; import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
import org.bukkit.entity.MushroomCow; import org.bukkit.entity.MushroomCow;
import java.util.Locale;
/** /**
* Created by libraryaddict on 6/05/2019. * Created by libraryaddict on 6/05/2019.
*/ */
@ -16,12 +18,12 @@ public class MushroomCowWatcher extends AgeableWatcher {
@NmsAddedIn(NmsVersion.v1_14) @NmsAddedIn(NmsVersion.v1_14)
public MushroomCow.Variant getVariant() { public MushroomCow.Variant getVariant() {
return MushroomCow.Variant.valueOf(getData(MetaIndex.MUSHROOM_COW_TYPE).toUpperCase()); return MushroomCow.Variant.valueOf(getData(MetaIndex.MUSHROOM_COW_TYPE).toUpperCase(Locale.ENGLISH));
} }
@NmsAddedIn(NmsVersion.v1_14) @NmsAddedIn(NmsVersion.v1_14)
public void setVariant(MushroomCow.Variant variant) { public void setVariant(MushroomCow.Variant variant) {
setData(MetaIndex.MUSHROOM_COW_TYPE, variant.name().toLowerCase()); setData(MetaIndex.MUSHROOM_COW_TYPE, variant.name().toLowerCase(Locale.ENGLISH));
sendData(MetaIndex.MUSHROOM_COW_TYPE); sendData(MetaIndex.MUSHROOM_COW_TYPE);
} }
} }

View File

@ -410,7 +410,7 @@ public class DisguiseUtilities {
} }
public static boolean hasGameProfile(String playername) { public static boolean hasGameProfile(String playername) {
return cachedNames.contains(playername.toLowerCase()); return cachedNames.contains(playername.toLowerCase(Locale.ENGLISH));
} }
public static void createClonedDisguise(Player player, Entity toClone, Boolean[] options) { public static void createClonedDisguise(Player player, Entity toClone, Boolean[] options) {
@ -674,12 +674,12 @@ public class DisguiseUtilities {
profileCache.mkdirs(); profileCache.mkdirs();
} }
File file = new File(profileCache, string.toLowerCase()); File file = new File(profileCache, string.toLowerCase(Locale.ENGLISH));
PrintWriter writer = new PrintWriter(file); PrintWriter writer = new PrintWriter(file);
writer.write(gson.toJson(gameProfile)); writer.write(gson.toJson(gameProfile));
writer.close(); writer.close();
cachedNames.add(string.toLowerCase()); cachedNames.add(string.toLowerCase(Locale.ENGLISH));
} catch (StackOverflowError | Exception e) { } catch (StackOverflowError | Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -888,7 +888,7 @@ public class DisguiseUtilities {
} }
public static WrappedGameProfile getGameProfile(String playerName) { public static WrappedGameProfile getGameProfile(String playerName) {
playerName = playerName.toLowerCase(); playerName = playerName.toLowerCase(Locale.ENGLISH);
if (!hasGameProfile(playerName)) { if (!hasGameProfile(playerName)) {
return null; return null;
@ -914,7 +914,7 @@ public class DisguiseUtilities {
} catch (JsonSyntaxException ex) { } catch (JsonSyntaxException ex) {
DisguiseUtilities.getLogger() DisguiseUtilities.getLogger()
.warning("Gameprofile " + file.getName() + " had invalid gson and has been deleted"); .warning("Gameprofile " + file.getName() + " had invalid gson and has been deleted");
cachedNames.remove(playerName.toLowerCase()); cachedNames.remove(playerName);
file.delete(); file.delete();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -1019,7 +1019,7 @@ public class DisguiseUtilities {
private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable, private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable,
boolean contactMojang) { boolean contactMojang) {
final String playerName = origName.toLowerCase(); final String playerName = origName.toLowerCase(Locale.ENGLISH);
if (DisguiseConfig.isSaveGameProfiles() && hasGameProfile(playerName)) { if (DisguiseConfig.isSaveGameProfiles() && hasGameProfile(playerName)) {
WrappedGameProfile profile = getGameProfile(playerName); WrappedGameProfile profile = getGameProfile(playerName);
@ -1153,7 +1153,7 @@ public class DisguiseUtilities {
cachedNames.addAll(Arrays.asList(profileCache.list())); cachedNames.addAll(Arrays.asList(profileCache.list()));
invalidFile = invalidFile =
LibsDisguises.getInstance().getFile().getName().toLowerCase().matches(".*((crack)|(null)|(leak)).*"); LibsDisguises.getInstance().getFile().getName().toLowerCase(Locale.ENGLISH).matches(".*((crack)|(null)|(leak)).*");
for (String key : savedDisguises.list()) { for (String key : savedDisguises.list()) {
try { try {
@ -1457,13 +1457,13 @@ public class DisguiseUtilities {
} }
public static void removeGameProfile(String string) { public static void removeGameProfile(String string) {
cachedNames.remove(string.toLowerCase()); cachedNames.remove(string.toLowerCase(Locale.ENGLISH));
if (!profileCache.exists()) { if (!profileCache.exists()) {
profileCache.mkdirs(); profileCache.mkdirs();
} }
File file = new File(profileCache, string.toLowerCase()); File file = new File(profileCache, string.toLowerCase(Locale.ENGLISH));
file.delete(); file.delete();
} }

View File

@ -10,6 +10,7 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.io.File; import java.io.File;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -165,7 +166,7 @@ public class SkinUtils {
} }
public static void grabSkin(String param, SkinCallback callback) { public static void grabSkin(String param, SkinCallback callback) {
ModelType modelType = param.toLowerCase().endsWith(":slim") ? ModelType.SLIM : ModelType.NORMAL; ModelType modelType = param.toLowerCase(Locale.ENGLISH).endsWith(":slim") ? ModelType.SLIM : ModelType.NORMAL;
if (modelType == ModelType.SLIM) { if (modelType == ModelType.SLIM) {
param = param.substring(0, param.length() - ":slim".length()); param = param.substring(0, param.length() - ":slim".length());
@ -184,12 +185,12 @@ public class SkinUtils {
} }
File file = new File(LibsDisguises.getInstance().getDataFolder(), File file = new File(LibsDisguises.getInstance().getDataFolder(),
"/Skins/" + param + (param.toLowerCase().endsWith(".png") ? "" : ".png")); "/Skins/" + param + (param.toLowerCase(Locale.ENGLISH).endsWith(".png") ? "" : ".png"));
if (!file.exists()) { if (!file.exists()) {
file = null; file = null;
if (param.toLowerCase().endsWith(".png")) { if (param.toLowerCase(Locale.ENGLISH).endsWith(".png")) {
callback.onError(LibsMsg.SKIN_API_BAD_FILE_NAME); callback.onError(LibsMsg.SKIN_API_BAD_FILE_NAME);
return; return;
} }

View File

@ -22,6 +22,7 @@ import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -185,7 +186,7 @@ public class ModdedManager {
continue; continue;
} }
if (mods.contains(e.getMod().toLowerCase())) { if (mods.contains(e.getMod().toLowerCase(Locale.ENGLISH))) {
continue; continue;
} }

View File

@ -21,6 +21,7 @@ import javax.annotation.Nullable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
public class ParamInfoManager { public class ParamInfoManager {
private static List<ParamInfo> paramList; private static List<ParamInfo> paramList;
@ -79,7 +80,7 @@ public class ParamInfoManager {
public static ParamInfo getParamInfo(DisguiseType disguiseType, String methodName) { public static ParamInfo getParamInfo(DisguiseType disguiseType, String methodName) {
for (Method method : getDisguiseWatcherMethods(disguiseType.getWatcherClass())) { for (Method method : getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
if (!method.getName().toLowerCase().equals(methodName.toLowerCase())) if (!method.getName().toLowerCase(Locale.ENGLISH).equals(methodName.toLowerCase(Locale.ENGLISH)))
continue; continue;
return getParamInfo(method); return getParamInfo(method);

View File

@ -207,7 +207,7 @@ public class ParamInfoTypes {
String[] split = string.split("_"); String[] split = string.split("_");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(Locale.ENGLISH);
} }
return StringUtils.join(split, "_"); return StringUtils.join(split, "_");

View File

@ -9,6 +9,7 @@ import org.bukkit.block.data.BlockData;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Set; import java.util.Set;
/** /**
@ -72,7 +73,7 @@ public class ParamInfoBlockData extends ParamInfo {
@Override @Override
public Set<String> getEnums(String tabComplete) { public Set<String> getEnums(String tabComplete) {
String s = tabComplete.toLowerCase(); String s = tabComplete.toLowerCase(Locale.ENGLISH);
HashSet<String> returns = new HashSet<>(); HashSet<String> returns = new HashSet<>();
if (s.matches("[a-z_:]+\\[.*")) { if (s.matches("[a-z_:]+\\[.*")) {
@ -83,11 +84,11 @@ public class ParamInfoBlockData extends ParamInfo {
continue; continue;
} }
if (!m.name().toLowerCase().startsWith(s) && !m.getKey().toString().startsWith(s)) { if (!m.name().toLowerCase(Locale.ENGLISH).startsWith(s) && !m.getKey().toString().startsWith(s)) {
continue; continue;
} }
if (m.name().toLowerCase().startsWith(s)) { if (m.name().toLowerCase(Locale.ENGLISH).startsWith(s)) {
returns.add(m.name()); returns.add(m.name());
} else { } else {
returns.add(m.getKey().toString()); returns.add(m.getKey().toString());

View File

@ -6,6 +6,7 @@ import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
/** /**
* Created by libraryaddict on 16/02/2020. * Created by libraryaddict on 16/02/2020.
@ -48,10 +49,10 @@ public class ParamInfoItemBlock extends ParamInfoItemStack {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
Material material = ReflectionManager.getMaterial(split[0].toLowerCase()); Material material = ReflectionManager.getMaterial(split[0].toLowerCase(Locale.ENGLISH));
if (material == null || material == Material.AIR) { if (material == null || material == Material.AIR) {
material = Material.getMaterial(split[0].toUpperCase()); material = Material.getMaterial(split[0].toUpperCase(Locale.ENGLISH));
} }
if (material == null || (material == Material.AIR && !split[0].equalsIgnoreCase("air"))) { if (material == null || (material == Material.AIR && !split[0].equalsIgnoreCase("air"))) {

View File

@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
/** /**
* Created by libraryaddict on 7/09/2018. * Created by libraryaddict on 7/09/2018.
@ -130,10 +131,10 @@ public class ParamInfoItemStack extends ParamInfoEnum {
split = string.split("[ -]"); split = string.split("[ -]");
} }
Material material = ReflectionManager.getMaterial(split[0].toLowerCase()); Material material = ReflectionManager.getMaterial(split[0].toLowerCase(Locale.ENGLISH));
if (material == null) { if (material == null) {
material = Material.getMaterial(split[0].toUpperCase()); material = Material.getMaterial(split[0].toUpperCase(Locale.ENGLISH));
} }
if (material == null || (material == Material.AIR && !split[0].equalsIgnoreCase("air"))) { if (material == null || (material == Material.AIR && !split[0].equalsIgnoreCase("air"))) {
@ -164,7 +165,7 @@ public class ParamInfoItemStack extends ParamInfoEnum {
return null; return null;
} }
Material material = Material.getMaterial(split[0].toUpperCase()); Material material = Material.getMaterial(split[0].toUpperCase(Locale.ENGLISH));
if (material == null || (material == Material.AIR && !split[0].equalsIgnoreCase("air"))) { if (material == null || (material == Material.AIR && !split[0].equalsIgnoreCase("air"))) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();

View File

@ -6,6 +6,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set; import java.util.Set;
/** /**
@ -37,7 +38,7 @@ public class ParamInfoItemStackArray extends ParamInfoItemStack {
String lastEntry = split.remove(split.size() - 1); String lastEntry = split.remove(split.size() - 1);
for (String material : super.getEnums(null)) { for (String material : super.getEnums(null)) {
if (!split.isEmpty() && !material.toLowerCase().startsWith(lastEntry.toLowerCase())) if (!split.isEmpty() && !material.toLowerCase(Locale.ENGLISH).startsWith(lastEntry.toLowerCase(Locale.ENGLISH)))
continue; continue;
toReturn.add(StringUtils.join(split, ",") + (split.isEmpty() ? "" : ",") + material); toReturn.add(StringUtils.join(split, ",") + (split.isEmpty() ? "" : ",") + material);

View File

@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Set; import java.util.Set;
/** /**
@ -38,7 +39,7 @@ public class ParamInfoParticle extends ParamInfoEnum {
enums = new HashSet<>(enums); enums = new HashSet<>(enums);
tabComplete = tabComplete.toUpperCase(); tabComplete = tabComplete.toUpperCase(Locale.ENGLISH);
for (Particle particle : new Particle[]{Particle.BLOCK_CRACK, Particle.BLOCK_DUST, Particle.ITEM_CRACK}) { for (Particle particle : new Particle[]{Particle.BLOCK_CRACK, Particle.BLOCK_DUST, Particle.ITEM_CRACK}) {
for (Material mat : materials) { for (Material mat : materials) {

View File

@ -264,7 +264,7 @@ public class DisguiseParser {
// libsdisguises.options.<command>.<disguise>.<method>.<options> // libsdisguises.options.<command>.<disguise>.<method>.<options>
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) { for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
String lowerPerm = permission.getPermission().toLowerCase(); String lowerPerm = permission.getPermission().toLowerCase(Locale.ENGLISH);
if (!lowerPerm.startsWith("libsdisguises.options.")) { if (!lowerPerm.startsWith("libsdisguises.options.")) {
continue; continue;
@ -382,7 +382,7 @@ public class DisguiseParser {
*/ */
private static boolean hasPermissionOption(HashMap<String, HashMap<String, Boolean>> disguiseOptions, String method, private static boolean hasPermissionOption(HashMap<String, HashMap<String, Boolean>> disguiseOptions, String method,
String value) { String value) {
method = method.toLowerCase(); method = method.toLowerCase(Locale.ENGLISH);
// If no permissions were defined, return true // If no permissions were defined, return true
if (!disguiseOptions.containsKey(method)) { if (!disguiseOptions.containsKey(method)) {
@ -391,7 +391,7 @@ public class DisguiseParser {
HashMap<String, Boolean> map = disguiseOptions.get(method); HashMap<String, Boolean> map = disguiseOptions.get(method);
value = value.toLowerCase(); value = value.toLowerCase(Locale.ENGLISH);
// If they were explictly defined, can just return the value // If they were explictly defined, can just return the value
if (map.containsKey(value)) { if (map.containsKey(value)) {
@ -529,7 +529,7 @@ public class DisguiseParser {
} }
public static long parseStringToTime(String string) throws DisguiseParseException { public static long parseStringToTime(String string) throws DisguiseParseException {
string = string.toLowerCase(); string = string.toLowerCase(Locale.ENGLISH);
if (!string.matches("([0-9]+[a-z]+)+")) { if (!string.matches("([0-9]+[a-z]+)+")) {
throw new DisguiseParseException(LibsMsg.PARSE_INVALID_TIME_SEQUENCE, string); throw new DisguiseParseException(LibsMsg.PARSE_INVALID_TIME_SEQUENCE, string);
@ -666,7 +666,7 @@ public class DisguiseParser {
if (args[0].startsWith("@")) { if (args[0].startsWith("@")) {
if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) { if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
disguise = DisguiseUtilities.getClonedDisguise(args[0].toLowerCase()); disguise = DisguiseUtilities.getClonedDisguise(args[0].toLowerCase(Locale.ENGLISH));
if (disguise == null) { if (disguise == null) {
throw new DisguiseParseException(LibsMsg.PARSE_NO_REF, args[0]); throw new DisguiseParseException(LibsMsg.PARSE_NO_REF, args[0]);
@ -743,7 +743,7 @@ public class DisguiseParser {
throw new DisguiseParseException(LibsMsg.PARSE_SUPPLY_PLAYER); throw new DisguiseParseException(LibsMsg.PARSE_SUPPLY_PLAYER);
} else { } else {
// If they can't use this name, throw error // If they can't use this name, throw error
if (!hasPermissionOption(disguiseOptions, "setname", args[1].toLowerCase())) { if (!hasPermissionOption(disguiseOptions, "setname", args[1].toLowerCase(Locale.ENGLISH))) {
if (!args[1].equalsIgnoreCase(sender.getName()) || if (!args[1].equalsIgnoreCase(sender.getName()) ||
!hasPermissionOption(disguiseOptions, "setname", "themselves")) { !hasPermissionOption(disguiseOptions, "setname", "themselves")) {
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_NAME); throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_NAME);
@ -829,7 +829,7 @@ public class DisguiseParser {
usedOptions.add(optionName); usedOptions.add(optionName);
doCheck(sender, permissions, disguisePerm, usedOptions); doCheck(sender, permissions, disguisePerm, usedOptions);
String itemName = itemStack == null ? "null" : itemStack.getType().name().toLowerCase(); String itemName = itemStack == null ? "null" : itemStack.getType().name().toLowerCase(Locale.ENGLISH);
if (!hasPermissionOption(disguiseOptions, optionName, itemName)) { if (!hasPermissionOption(disguiseOptions, optionName, itemName)) {
throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, itemName, throw new DisguiseParseException(LibsMsg.PARSE_NO_PERM_PARAM, itemName,
@ -964,8 +964,8 @@ public class DisguiseParser {
throw new DisguiseParseException(LibsMsg.PARSE_OPTION_NA, methodNameProvided); throw new DisguiseParseException(LibsMsg.PARSE_OPTION_NA, methodNameProvided);
} }
if (!usedOptions.contains(methodToUse.getName().toLowerCase())) { if (!usedOptions.contains(methodToUse.getName().toLowerCase(Locale.ENGLISH))) {
usedOptions.add(methodToUse.getName().toLowerCase()); usedOptions.add(methodToUse.getName().toLowerCase(Locale.ENGLISH));
} }
doCheck(sender, disguisePermission, disguisePerm, usedOptions); doCheck(sender, disguisePermission, disguisePerm, usedOptions);

View File

@ -106,7 +106,7 @@ public class DisguisePermissions {
* @param commandName A lowercase string consisting of the name of one of Lib's Disguises commands * @param commandName A lowercase string consisting of the name of one of Lib's Disguises commands
*/ */
public DisguisePermissions(Permissible permissionHolder, String commandName) { public DisguisePermissions(Permissible permissionHolder, String commandName) {
loadPermissions(permissionHolder, commandName.toLowerCase()); loadPermissions(permissionHolder, commandName.toLowerCase(Locale.ENGLISH));
} }
/** /**
@ -197,7 +197,7 @@ public class DisguisePermissions {
} }
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) { for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
String perm = permission.getPermission().toLowerCase(); String perm = permission.getPermission().toLowerCase(Locale.ENGLISH);
String[] split = perm.split("\\."); String[] split = perm.split("\\.");
@ -467,14 +467,14 @@ public class DisguisePermissions {
if (!storage.permittedOptions.isEmpty() || storage.negatedOptions.isEmpty()) { if (!storage.permittedOptions.isEmpty() || storage.negatedOptions.isEmpty()) {
// Check if they're trying to use anything they shouldn't // Check if they're trying to use anything they shouldn't
if (!disguiseOptions.stream() if (!disguiseOptions.stream()
.allMatch(option -> storage.permittedOptions.contains(option.toLowerCase()))) { .allMatch(option -> storage.permittedOptions.contains(option.toLowerCase(Locale.ENGLISH)))) {
return false; return false;
} }
} }
} }
// If the user is using a forbidden option, return false. Otherwise true // If the user is using a forbidden option, return false. Otherwise true
return disguiseOptions.stream().noneMatch(option -> storage.negatedOptions.contains(option.toLowerCase())); return disguiseOptions.stream().noneMatch(option -> storage.negatedOptions.contains(option.toLowerCase(Locale.ENGLISH)));
} }
public boolean isAllowedDisguise(DisguisePerm disguisePerm) { public boolean isAllowedDisguise(DisguisePerm disguisePerm) {

View File

@ -8,6 +8,7 @@ import java.net.URLDecoder;
import java.security.CodeSource; import java.security.CodeSource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Locale;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
@ -31,7 +32,7 @@ public class ClassGetter {
if (src != null) { if (src != null) {
URL resource = src.getLocation(); URL resource = src.getLocation();
if (resource.getPath().toLowerCase().endsWith(".jar")) { if (resource.getPath().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
processJarfile(resource, pkgname, classes); processJarfile(resource, pkgname, classes);
} else { } else {
for (File f : new File(resource.getPath() + "/" + pkgname.replace(".", "/")).listFiles()) { for (File f : new File(resource.getPath() + "/" + pkgname.replace(".", "/")).listFiles()) {

View File

@ -106,10 +106,6 @@ public class ReflectionManager {
private static Object genericDamage; private static Object genericDamage;
public static void init() { public static void init() {
// Sometimes it doesn't like me if I don't set this :\
// Weird characters in toLowerCase() for example
Locale.setDefault(Locale.ENGLISH);
try { try {
boundingBoxConstructor = boundingBoxConstructor =
getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class, double.class, getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class, double.class,
@ -1373,7 +1369,7 @@ public class ReflectionManager {
public static Object getEntityType(EntityType entityType) { public static Object getEntityType(EntityType entityType) {
try { try {
Object val = entityTypesAMethod.invoke(null, Object val = entityTypesAMethod.invoke(null,
entityType.getName() == null ? entityType.name().toLowerCase() : entityType.getName()); entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName());
if (NmsVersion.v1_14.isSupported()) { if (NmsVersion.v1_14.isSupported()) {
return ((Optional<Object>) val).orElse(null); return ((Optional<Object>) val).orElse(null);
@ -1958,7 +1954,7 @@ public class ReflectionManager {
String[] split = string.split("_"); String[] split = string.split("_");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
split[i] = split[i].charAt(0) + split[i].substring(1).toLowerCase(); split[i] = split[i].charAt(0) + split[i].substring(1).toLowerCase(Locale.ENGLISH);
} }
return split; return split;

View File

@ -10,6 +10,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.*; import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -53,7 +54,7 @@ public class SoundManager {
} }
List<String> list = section List<String> list = section
.getStringList(type.name().charAt(0) + type.name().substring(1).toLowerCase()); .getStringList(type.name().charAt(0) + type.name().substring(1).toLowerCase(Locale.ENGLISH));
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
continue; continue;

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.EntityType;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Locale;
/** /**
* Created by libraryaddict on 10/06/2017. * Created by libraryaddict on 10/06/2017.
@ -48,7 +49,7 @@ public class TranslateFiller {
String[] split = type.name().split("_"); String[] split = type.name().split("_");
for (int i = 0; i < split.length; i++) { for (int i = 0; i < split.length; i++) {
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); split[i] = split[i].charAt(0) + split[i].substring(1).toLowerCase(Locale.ENGLISH);
} }
TranslateType.DISGUISES.save(StringUtils.join(split, " "), "Name for the " + type.name() + " disguise"); TranslateType.DISGUISES.save(StringUtils.join(split, " "), "Name for the " + type.name() + " disguise");

View File

@ -10,10 +10,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.*;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
/** /**
* Created by libraryaddict on 10/06/2017. * Created by libraryaddict on 10/06/2017.
@ -198,10 +195,10 @@ public enum TranslateType {
if (translated == null || !LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations()) if (translated == null || !LibsPremium.isPremium() || !DisguiseConfig.isUseTranslations())
return translated; return translated;
String lowerCase = translated.toLowerCase(); String lowerCase = translated.toLowerCase(Locale.ENGLISH);
for (Map.Entry<String, String> entry : this.translated.entrySet()) { for (Map.Entry<String, String> entry : this.translated.entrySet()) {
if (!Objects.equals(entry.getValue().toLowerCase(), lowerCase)) if (!Objects.equals(entry.getValue().toLowerCase(Locale.ENGLISH), lowerCase))
continue; continue;
return entry.getKey(); return entry.getKey();

View File

@ -157,7 +157,7 @@ public class LDJenkins {
changelog.add("#" + map.get("id") + ": " + ChatColor.YELLOW + msg); changelog.add("#" + map.get("id") + ": " + ChatColor.YELLOW + msg);
release = release || msg.toLowerCase().matches("(re)?.?release.? .*"); release = release || msg.toLowerCase(Locale.ENGLISH).matches("(re)?.?release.? .*");
} }
} }