More uniformly apply Configuration.caseSensitiveCustomCategories. Closes #1353

This commit is contained in:
LexManos 2016-05-28 18:04:29 -07:00
parent 4824d647f4
commit 35978b0d96
1 changed files with 10 additions and 24 deletions

View File

@ -114,7 +114,7 @@ public class Configuration
File fileBak = new File(file.getAbsolutePath() + "_" +
new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ".errored");
FMLLog.severe("An exception occurred while loading config file %s. This file will be renamed to %s " +
"and a new config file will be generated.", file.getName(), fileBak.getName());
"and a new config file will be generated.", file.getName(), fileBak.getName());
e.printStackTrace();
file.renameTo(fileBak);
@ -688,11 +688,6 @@ public class Configuration
*/
public Property get(String category, String key, String defaultValue, String comment, Property.Type type)
{
if (!caseSensitiveCustomCategories)
{
category = category.toLowerCase(Locale.ENGLISH);
}
ConfigCategory cat = getCategory(category);
if (cat.containsKey(key))
@ -736,11 +731,6 @@ public class Configuration
*/
public Property get(String category, String key, String[] defaultValues, String comment, Property.Type type)
{
if (!caseSensitiveCustomCategories)
{
category = category.toLowerCase(Locale.ENGLISH);
}
ConfigCategory cat = getCategory(category);
if (cat.containsKey(key))
@ -780,11 +770,15 @@ public class Configuration
public boolean hasCategory(String category)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
return categories.get(category) != null;
}
public boolean hasKey(String category, String key)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
ConfigCategory cat = categories.get(category);
return cat != null && cat.containsKey(key);
}
@ -906,6 +900,8 @@ public class Configuration
if (tmpList != null) // allow special characters as part of string lists
break;
name = line.substring(nameStart, nameEnd + 1);
if (!caseSensitiveCustomCategories)
name = name.toLowerCase(Locale.ENGLISH);
String qualifiedName = ConfigCategory.getQualifiedName(name, currentCat);
ConfigCategory cat = categories.get(qualifiedName);
@ -1119,6 +1115,9 @@ public class Configuration
public ConfigCategory getCategory(String category)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
ConfigCategory ret = categories.get(category);
if (ret == null)
@ -1188,8 +1187,6 @@ public class Configuration
*/
public Configuration setCategoryComment(String category, String comment)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
getCategory(category).setComment(comment);
return this;
}
@ -1207,8 +1204,6 @@ public class Configuration
*/
public Configuration setCategoryLanguageKey(String category, String langKey)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
getCategory(category).setLanguageKey(langKey);
return this;
}
@ -1221,9 +1216,6 @@ public class Configuration
*/
public Configuration setCategoryConfigEntryClass(String category, Class<? extends IConfigEntry> clazz)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
getCategory(category).setConfigEntryClass(clazz);
return this;
}
@ -1235,8 +1227,6 @@ public class Configuration
*/
public Configuration setCategoryRequiresWorldRestart(String category, boolean requiresWorldRestart)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
getCategory(category).setRequiresWorldRestart(requiresWorldRestart);
return this;
}
@ -1249,8 +1239,6 @@ public class Configuration
*/
public Configuration setCategoryRequiresMcRestart(String category, boolean requiresMcRestart)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
getCategory(category).setRequiresMcRestart(requiresMcRestart);
return this;
}
@ -1261,8 +1249,6 @@ public class Configuration
*/
public Configuration setCategoryPropertyOrder(String category, List<String> propOrder)
{
if (!caseSensitiveCustomCategories)
category = category.toLowerCase(Locale.ENGLISH);
getCategory(category).setPropertyOrder(propOrder);
return this;
}