Skip to content

Commit

Permalink
Use toLowerCase(Locale.ROOT) in TownySettings (#6227)
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr authored Oct 13, 2022
1 parent b80631e commit 5295d65
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/com/palmergames/bukkit/towny/TownySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -413,39 +413,39 @@ public static SpawnLevel getSpawnLevel(ConfigNodes node)

public static boolean getBoolean(ConfigNodes node) {

return Boolean.parseBoolean(config.getString(node.getRoot().toLowerCase(), node.getDefault()));
return Boolean.parseBoolean(config.getString(node.getRoot().toLowerCase(Locale.ROOT), node.getDefault()));
}

public static double getDouble(ConfigNodes node) {

try {
return Double.parseDouble(config.getString(node.getRoot().toLowerCase(), node.getDefault()).trim());
return Double.parseDouble(config.getString(node.getRoot().toLowerCase(Locale.ROOT), node.getDefault()).trim());
} catch (NumberFormatException e) {
sendError(node.getRoot().toLowerCase() + " from config.yml");
sendError(node.getRoot().toLowerCase(Locale.ROOT) + " from config.yml");
return 0.0;
}
}

public static int getInt(ConfigNodes node) {

try {
return Integer.parseInt(config.getString(node.getRoot().toLowerCase(), node.getDefault()).trim());
return Integer.parseInt(config.getString(node.getRoot().toLowerCase(Locale.ROOT), node.getDefault()).trim());
} catch (NumberFormatException e) {
sendError(node.getRoot().toLowerCase() + " from config.yml");
sendError(node.getRoot().toLowerCase(Locale.ROOT) + " from config.yml");
return 0;
}
}

public static String getString(ConfigNodes node) {

return config.getString(node.getRoot().toLowerCase(), node.getDefault());
return config.getString(node.getRoot().toLowerCase(Locale.ROOT), node.getDefault());
}

public static String getString(String root, String def) {

String data = config.getString(root.toLowerCase(), def);
String data = config.getString(root.toLowerCase(Locale.ROOT), def);
if (data == null) {
sendError(root.toLowerCase() + " from config.yml");
sendError(root.toLowerCase(Locale.ROOT) + " from config.yml");
return "";
}
return data;
Expand All @@ -460,15 +460,15 @@ public static List<Integer> getIntArr(ConfigNodes node) {
try {
list.add(Integer.parseInt(aStrArray.trim()));
} catch (NumberFormatException e) {
sendError(node.getRoot().toLowerCase() + " from config.yml");
sendError(node.getRoot().toLowerCase(Locale.ROOT) + " from config.yml");
}
}
return list;
}

public static List<String> getStrArr(ConfigNodes node) {

String[] strArray = getString(node.getRoot().toLowerCase(), node.getDefault()).split(",");
String[] strArray = getString(node.getRoot().toLowerCase(Locale.ROOT), node.getDefault()).split(",");
List<String> list = new ArrayList<>();
if (strArray.length > 0) {
for (String aStrArray : strArray)
Expand All @@ -483,14 +483,14 @@ public static long getSeconds(ConfigNodes node) {
try {
return TimeTools.getSeconds(getString(node));
} catch (NumberFormatException e) {
sendError(node.getRoot().toLowerCase() + " from config.yml");
sendError(node.getRoot().toLowerCase(Locale.ROOT) + " from config.yml");
return 1;
}
}

public static void addComment(String root, String... comments) {

newConfig.addComment(root.toLowerCase(), comments);
newConfig.addComment(root.toLowerCase(Locale.ROOT), comments);
}

/**
Expand Down Expand Up @@ -523,7 +523,7 @@ private static void setDefaults(String version, Path configPath) {
setNewProperty(root.getRoot(), root.getDefault());
setTownBlockTypes();
} else
setNewProperty(root.getRoot(), (config.get(root.getRoot().toLowerCase()) != null) ? config.get(root.getRoot().toLowerCase()) : root.getDefault());
setNewProperty(root.getRoot(), (config.get(root.getRoot().toLowerCase(Locale.ROOT)) != null) ? config.get(root.getRoot().toLowerCase(Locale.ROOT)) : root.getDefault());

}

Expand Down Expand Up @@ -1568,16 +1568,16 @@ public static List<String> getPotionTypes() {

public static void setProperty(String root, Object value) {

config.set(root.toLowerCase(), value.toString());
config.set(root.toLowerCase(Locale.ROOT), value.toString());
}

private static void setNewProperty(String root, Object value) {

if (value == null) {
TownyMessaging.sendDebugMsg("value is null for " + root.toLowerCase());
TownyMessaging.sendDebugMsg("value is null for " + root.toLowerCase(Locale.ROOT));
value = "";
}
newConfig.set(root.toLowerCase(), value.toString());
newConfig.set(root.toLowerCase(Locale.ROOT), value.toString());
}

public static void setLanguage(String lang) {
Expand All @@ -1587,7 +1587,7 @@ public static void setLanguage(String lang) {

public static Object getProperty(String root) {

return config.get(root.toLowerCase());
return config.get(root.toLowerCase(Locale.ROOT));
}

public static double getClaimPrice() {
Expand Down

0 comments on commit 5295d65

Please sign in to comment.