From 35978b0d962157fea5b7525e22f51a183d7f796b Mon Sep 17 00:00:00 2001 From: LexManos Date: Sat, 28 May 2016 18:04:29 -0700 Subject: [PATCH] More uniformly apply Configuration.caseSensitiveCustomCategories. Closes #1353 --- .../common/config/Configuration.java | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/main/java/net/minecraftforge/common/config/Configuration.java b/src/main/java/net/minecraftforge/common/config/Configuration.java index 13c34e06c..759a806cd 100644 --- a/src/main/java/net/minecraftforge/common/config/Configuration.java +++ b/src/main/java/net/minecraftforge/common/config/Configuration.java @@ -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 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 propOrder) { - if (!caseSensitiveCustomCategories) - category = category.toLowerCase(Locale.ENGLISH); getCategory(category).setPropertyOrder(propOrder); return this; }