Added config option to make .new config files instead over writing over old ones when updating

This commit is contained in:
NuclearW 2013-02-22 11:59:56 -05:00
parent d052d7a3ce
commit 3b07d4055a
4 changed files with 12 additions and 1 deletions

View File

@ -36,6 +36,8 @@ Version 1.4.00-dev
+ Added config option to disable automatic zip backups. + Added config option to disable automatic zip backups.
+ Added particle effects for many abilities. + Added particle effects for many abilities.
+ Added '/mcnotify' command to toggle ability notifications on/off + Added '/mcnotify' command to toggle ability notifications on/off
+ Added ability for config files to automatically update with new keys, and prune out old ones
+ Added config option to make .new config files instead over writing over old ones when updating
= Fixed Green Thumb on wheat not working properly at rank 4 = Fixed Green Thumb on wheat not working properly at rank 4
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed = Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
= Fixed Green Terra not also checking Green Thumb permissions = Fixed Green Terra not also checking Green Thumb permissions

View File

@ -44,6 +44,7 @@ public class Config extends ConfigLoader {
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); } public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); } public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); } public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); } public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); } public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }

View File

@ -121,7 +121,13 @@ public abstract class ConfigLoader {
// Save it // Save it
try { try {
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), fileName))); String saveName = fileName;
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
saveName += ".new";
}
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
writer.write(output); writer.write(output);
writer.flush(); writer.flush();
writer.close(); writer.close();

View File

@ -24,6 +24,8 @@ General:
Power_Level_Cap: 0 Power_Level_Cap: 0
#Should mcMMO print out debug messages? #Should mcMMO print out debug messages?
Verbose_Logging: false Verbose_Logging: false
#Should mcMMO over-write configs to update, or make new ones ending in .new?
Config_Update_Overwrite: true
Database_Purging: Database_Purging:
#Amount of time (in hours) to wait between database purging #Amount of time (in hours) to wait between database purging