Added new FileConfigurationOptions.copyHeader, defaulting to true. Copies the header from default config, if there is one.

This commit is contained in:
Nathan Adams
2011-10-12 13:24:57 +01:00
parent ab46572125
commit 98633dfddf
6 changed files with 153 additions and 54 deletions

View File

@@ -7,6 +7,7 @@ import org.bukkit.configuration.*;
*/
public class FileConfigurationOptions extends MemoryConfigurationOptions {
private String header = null;
private boolean copyHeader = true;
protected FileConfigurationOptions(MemoryConfiguration configuration) {
super(configuration);
@@ -64,4 +65,45 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
this.header = value;
return this;
}
/**
* Gets whether or not the header should be copied from a default source.
* <p>
* If this is true, if a default {@link FileConfiguration} is passed to
* {@link FileConfiguration#setDefaults(org.bukkit.configuration.Configuration)}
* then upon saving it will use the header from that config, instead of the one provided here.
* <p>
* If no default is set on the configuration, or the default is not of type FileConfiguration,
* or that config has no header ({@link #header()} returns null) then the header
* specified in this configuration will be used.
* <p>
* Defaults to true.
*
* @return Whether or not to copy the header
*/
public boolean copyHeader() {
return copyHeader;
}
/**
* Sets whether or not the header should be copied from a default source.
* <p>
* If this is true, if a default {@link FileConfiguration} is passed to
* {@link FileConfiguration#setDefaults(org.bukkit.configuration.Configuration)}
* then upon saving it will use the header from that config, instead of the one provided here.
* <p>
* If no default is set on the configuration, or the default is not of type FileConfiguration,
* or that config has no header ({@link #header()} returns null) then the header
* specified in this configuration will be used.
* <p>
* Defaults to true.
*
* @param value Whether or not to copy the header
* @return This object, for chaining
*/
public FileConfigurationOptions copyHeader(boolean value) {
copyHeader = value;
return this;
}
}