@@ -165,6 +165,10 @@ private void readProperties(Properties props) {
165165 for (Map .Entry <Object , Object > entry : props .entrySet ()) {
166166 String key = (String ) entry .getKey ();
167167 String value = (String ) entry .getValue ();
168+ if (value .indexOf ('#' ) != -1 ) {
169+ value = value .substring (0 , value .indexOf ('#' ));
170+ }
171+ value = value .strip ();
168172
169173 Option option = this .options .get (key );
170174 if (option == null ) {
@@ -262,14 +266,13 @@ public void save() throws IOException {
262266 throw new IOException ("The parent file is not a directory" );
263267 }
264268
265- try (Writer writer = new FileWriter (configFile )) {
269+ try (Writer writer = new BufferedWriter ( new FileWriter (configFile ) )) {
266270 writer .write ("# This is the early configuration file for GregTech CEu Modern.\n " );
267271 writer .write ("# The following options can be enabled or disabled if there is a compatibility issue.\n " );
268- writer .write (
269- "# Add a line with your option name and =true or =false at the bottom of the file to enable\n " );
270- writer .write ("# or disable a rule. For example:\n " );
271- writer .write ("# client.bloom.safe_mode=true\n " );
272- writer .write ("# Do not include the #. You may reset to defaults by deleting this file.\n " );
272+ writer .write ("# Change the line with your option name and =true or =false to enable or disable a rule.\n " );
273+ writer .write ("# For example:\n " );
274+ writer .write ("# client.bloom.safe_mode=true -> client.bloom.safe_mode=false\n " );
275+ writer .write ("# Do not include the # or ->. You may reset to defaults by deleting this file.\n " );
273276 writer .write ("#\n " );
274277 writer .write ("# Available options:\n " );
275278 var entries = this .options .entrySet ().stream ()
@@ -278,35 +281,23 @@ public void save() throws IOException {
278281 .toList ();
279282
280283 for (var entry : entries ) {
281- String line = entry .getKey ();
284+ String key = entry .getKey ();
282285 Option option = entry .getValue ();
283286
284- String extraContext ;
285- if (!option .isUserDefined ()) {
286- extraContext = "=" + option .isEnabled () + " # " +
287- (option .isModDefined () ? "(overridden for mod compat)" : "(default)" );
288- } else {
289- extraContext = "=" + option .isDefaultEnabled () + " # (default)" ;
290- }
291-
292- writer .write ("#\n " );
287+ writer .write ('\n' );
293288 if (option .getComment () != null ) {
294289 for (String commentLine : option .getComment ()) {
295- writer .write ("# # " + commentLine + "\n " );
290+ writer .write ("# " + commentLine + "\n " );
296291 }
297292 }
298- writer .write ("# " + line + extraContext + "\n " );
299- }
300-
301- writer .write ("#\n " );
302- writer .write ("#\n " );
303- writer .write ("# User overrides go here.\n " );
304293
305- for (var entry : entries ) {
306- Option option = entry .getValue ();
307- if (option .isUserDefined ()) {
308- writer .write (entry .getKey () + "=" + option .isEnabled () + "\n " );
294+ writer .write ("# default: " + option .isDefaultEnabled ());
295+ if (!option .isUserDefined () && option .isModDefined ()) {
296+ writer .write (" (overridden for mod compat)" );
309297 }
298+ writer .write ('\n' );
299+
300+ writer .write (key + "=" + option .isEnabled () + "\n " );
310301 }
311302 }
312303 }
0 commit comments