Index: src/net/sourceforge/kolmafia/preferences/Preferences.java
===================================================================
--- src/net/sourceforge/kolmafia/preferences/Preferences.java (revision 12105)
+++ src/net/sourceforge/kolmafia/preferences/Preferences.java (working copy)
@@ -83,6 +83,8 @@
private static final HashMap globalNames = new HashMap();
private static final TreeMap globalValues = new TreeMap();
private static File globalPropertiesFile = null;
+
+ private static final TreeMap defaultsMap = new TreeMap();
static
{
@@ -601,6 +603,9 @@
String value = current.length == 2 ? "" : current[ 2 ];
desiredMap = map.equals( "global" ) ? Preferences.globalNames : Preferences.userNames;
desiredMap.put( name, value );
+
+ // Maintain a map of prefs that exist in defaults.txt
+ defaultsMap.put( name, value );
}
}
@@ -744,10 +749,24 @@
String name = (String) i.next();
if ( name.startsWith( "_" ) )
{
+ if ( !Preferences.containsDefault( name ) )
+ {
+ i.remove();
+ if ( Preferences.getBoolean( "saveSettingsOnSet" ) )
+ {
+ Preferences.saveToFile( Preferences.userPropertiesFile, Preferences.userValues );
+ }
+ continue;
+ }
String val = (String) Preferences.userNames.get( name );
if ( val == null ) val = "";
Preferences.setString( name, val );
}
}
}
+
+ public static boolean containsDefault( String key )
+ {
+ return defaultsMap.containsKey( key );
+ }
}
Index: src/net/sourceforge/kolmafia/textui/command/SetPreferencesCommand.java
===================================================================
--- src/net/sourceforge/kolmafia/textui/command/SetPreferencesCommand.java (revision 12105)
+++ src/net/sourceforge/kolmafia/textui/command/SetPreferencesCommand.java (working copy)
@@ -139,7 +139,8 @@
return;
}
- RequestLogger.printLine( name + " => " + value );
+ if ( !name.startsWith( "_" ) || Preferences.containsDefault( name ) )
+ RequestLogger.printLine( name + " => " + value );
Preferences.setString( name, value );
if ( name.startsWith( "combatHotkey" ) )