From 76d6bc3cfa5071ce203c2b8f9a4231ec7b2cfc24 Mon Sep 17 00:00:00 2001 From: LexManos Date: Wed, 12 Dec 2012 02:20:46 -0800 Subject: [PATCH] Fixes crash when mods add TreeMaps to the Configuration map, thanks AtomicStryker, PR: #282 --- .../minecraftforge/common/Configuration.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/common/net/minecraftforge/common/Configuration.java b/common/net/minecraftforge/common/Configuration.java index 9ce71b27e8..9f05b7a2d5 100644 --- a/common/net/minecraftforge/common/Configuration.java +++ b/common/net/minecraftforge/common/Configuration.java @@ -695,6 +695,28 @@ public class Configuration private void save(BufferedWriter out) throws IOException { + //For compatiblitties sake just in case, Thanks Atomic, to be removed next MC version + //TO-DO: Remove next MC version + Object[] categoryArray = categories.values().toArray(); + for (Object o : categoryArray) + { + if (o instanceof TreeMap) + { + TreeMap treeMap = (TreeMap)o; + ConfigCategory converted = new ConfigCategory(file.getName()); + FMLLog.warning("Forge found a Treemap saved for Configuration file " + file.getName() + ", this is deprecated behaviour!"); + + for (Object key : treeMap.keySet()) + { + FMLLog.warning("Converting Treemap to ConfigCategory, key: " + key + ", property value: " + ((Property)treeMap.get(key)).value); + converted.set((String)key, (Property)treeMap.get(key)); + } + + categories.values().remove(o); + categories.put(file.getName(), converted); + } + } + for (ConfigCategory cat : categories.values()) { if (!cat.isChild())