001 package org.bukkit.configuration.file; 002 003 import org.bukkit.configuration.*; 004 005 /** 006 * Various settings for controlling the input and output of a {@link 007 * FileConfiguration} 008 */ 009 public class FileConfigurationOptions extends MemoryConfigurationOptions { 010 private String header = null; 011 private boolean copyHeader = true; 012 013 protected FileConfigurationOptions(MemoryConfiguration configuration) { 014 super(configuration); 015 } 016 017 @Override 018 public FileConfiguration configuration() { 019 return (FileConfiguration) super.configuration(); 020 } 021 022 @Override 023 public FileConfigurationOptions copyDefaults(boolean value) { 024 super.copyDefaults(value); 025 return this; 026 } 027 028 @Override 029 public FileConfigurationOptions pathSeparator(char value) { 030 super.pathSeparator(value); 031 return this; 032 } 033 034 /** 035 * Gets the header that will be applied to the top of the saved output. 036 * <p> 037 * This header will be commented out and applied directly at the top of 038 * the generated output of the {@link FileConfiguration}. It is not 039 * required to include a newline at the end of the header as it will 040 * automatically be applied, but you may include one if you wish for extra 041 * spacing. 042 * <p> 043 * Null is a valid value which will indicate that no header is to be 044 * applied. The default value is null. 045 * 046 * @return Header 047 */ 048 public String header() { 049 return header; 050 } 051 052 /** 053 * Sets the header that will be applied to the top of the saved output. 054 * <p> 055 * This header will be commented out and applied directly at the top of 056 * the generated output of the {@link FileConfiguration}. It is not 057 * required to include a newline at the end of the header as it will 058 * automatically be applied, but you may include one if you wish for extra 059 * spacing. 060 * <p> 061 * Null is a valid value which will indicate that no header is to be 062 * applied. 063 * 064 * @param value New header 065 * @return This object, for chaining 066 */ 067 public FileConfigurationOptions header(String value) { 068 this.header = value; 069 return this; 070 } 071 072 /** 073 * Gets whether or not the header should be copied from a default source. 074 * <p> 075 * If this is true, if a default {@link FileConfiguration} is passed to 076 * {@link 077 * FileConfiguration#setDefaults(org.bukkit.configuration.Configuration)} 078 * then upon saving it will use the header from that config, instead of 079 * the one provided here. 080 * <p> 081 * If no default is set on the configuration, or the default is not of 082 * type FileConfiguration, or that config has no header ({@link #header()} 083 * returns null) then the header specified in this configuration will be 084 * used. 085 * <p> 086 * Defaults to true. 087 * 088 * @return Whether or not to copy the header 089 */ 090 public boolean copyHeader() { 091 return copyHeader; 092 } 093 094 /** 095 * Sets whether or not the header should be copied from a default source. 096 * <p> 097 * If this is true, if a default {@link FileConfiguration} is passed to 098 * {@link 099 * FileConfiguration#setDefaults(org.bukkit.configuration.Configuration)} 100 * then upon saving it will use the header from that config, instead of 101 * the one provided here. 102 * <p> 103 * If no default is set on the configuration, or the default is not of 104 * type FileConfiguration, or that config has no header ({@link #header()} 105 * returns null) then the header specified in this configuration will be 106 * used. 107 * <p> 108 * Defaults to true. 109 * 110 * @param value Whether or not to copy the header 111 * @return This object, for chaining 112 */ 113 public FileConfigurationOptions copyHeader(boolean value) { 114 copyHeader = value; 115 116 return this; 117 } 118 }