@@ -32,6 +32,31 @@ public static void configure() {
3232 }
3333 }
3434
35+ private static String titleCaseToCamelCase (String title ) {
36+ if (title == null || title .trim ().isEmpty ()) {
37+ return title ;
38+ }
39+
40+ String [] words = title .trim ().split ("\\ s+" );
41+ if (words .length == 0 ) {
42+ return "" ;
43+ }
44+
45+ StringBuilder result = new StringBuilder (words [0 ].toLowerCase ());
46+
47+ for (int i = 1 ; i < words .length ; i ++) {
48+ String word = words [i ];
49+ if (!word .isEmpty ()) {
50+ String camelWord =
51+ word .substring (0 , 1 ).toUpperCase () +
52+ word .substring (1 ).toLowerCase ();
53+ result .append (camelWord );
54+ }
55+ }
56+
57+ return result .toString ();
58+ }
59+
3560 public static void serialize () {
3661 Properties prop = new Properties ();
3762 HashMap <String , String > serialized = new HashMap <String , String >();
@@ -73,7 +98,6 @@ public static void deserialize() {
7398 map .put (name , prop .getProperty (name ));
7499 }
75100
76- int updatedCount = 0 ;
77101 for (Map .Entry <String , ModSettings > modEntry : settings .entrySet ()) {
78102 String modID = modEntry .getKey ();
79103 ModSettings modSetting = modEntry .getValue ();
@@ -82,10 +106,15 @@ public static void deserialize() {
82106 .getSettings ()
83107 .entrySet ()) {
84108 String fullKey = modID + "." + entry .getKey ();
109+ String oldConfigKey =
110+ modID + "." + titleCaseToCamelCase (entry .getKey ());
111+
85112 String val = map .get (fullKey );
113+ String oldVal = map .get (oldConfigKey );
86114 if (val != null ) {
87115 entry .getValue ().setValue (val );
88- updatedCount ++;
116+ } else if (oldVal != null ) {
117+ entry .getValue ().setValue (oldVal );
89118 }
90119 }
91120 }
@@ -101,13 +130,8 @@ public static void deserialize() {
101130 .getSetting ("Background Color" );
102131 if (bgSetting != null ) {
103132 bgSetting .setValue (globalBg );
104- updatedCount ++;
105133 }
106134 }
107- System .out .println (
108- // Remove this debug line in release
109- "Migrated global backgroundColor to all mods: " + globalBg
110- );
111135 }
112136
113137 String globalText = map .get ("textColor" );
@@ -121,18 +145,10 @@ public static void deserialize() {
121145 .getSetting ("Text Color" );
122146 if (textSetting != null ) {
123147 textSetting .setValue (globalText );
124- updatedCount ++;
125148 }
126149 }
127- System .out .println (
128- // Remove this debug line in release
129- "Migrated global textColor to all mods: " + globalText
130- );
131150 }
132151
133- // Ignore other old globals (e.g., horizontalMargin) unless you map them to specific settings
134-
135- System .out .println ("Deserialized " + updatedCount + " settings." ); // Remove this debug line in release
136- serialize (); // Re-save with migrated values
152+ serialize ();
137153 }
138154}
0 commit comments