001 package org.bukkit.configuration; 002 003 /** 004 * Various settings for controlling the input and output of a {@link 005 * Configuration} 006 */ 007 public class ConfigurationOptions { 008 private char pathSeparator = '.'; 009 private boolean copyDefaults = false; 010 private final Configuration configuration; 011 012 protected ConfigurationOptions(Configuration configuration) { 013 this.configuration = configuration; 014 } 015 016 /** 017 * Returns the {@link Configuration} that this object is responsible for. 018 * 019 * @return Parent configuration 020 */ 021 public Configuration configuration() { 022 return configuration; 023 } 024 025 /** 026 * Gets the char that will be used to separate {@link 027 * ConfigurationSection}s 028 * <p> 029 * This value does not affect how the {@link Configuration} is stored, 030 * only in how you access the data. The default value is '.'. 031 * 032 * @return Path separator 033 */ 034 public char pathSeparator() { 035 return pathSeparator; 036 } 037 038 /** 039 * Sets the char that will be used to separate {@link 040 * ConfigurationSection}s 041 * <p> 042 * This value does not affect how the {@link Configuration} is stored, 043 * only in how you access the data. The default value is '.'. 044 * 045 * @param value Path separator 046 * @return This object, for chaining 047 */ 048 public ConfigurationOptions pathSeparator(char value) { 049 this.pathSeparator = value; 050 return this; 051 } 052 053 /** 054 * Checks if the {@link Configuration} should copy values from its default 055 * {@link Configuration} directly. 056 * <p> 057 * If this is true, all values in the default Configuration will be 058 * directly copied, making it impossible to distinguish between values 059 * that were set and values that are provided by default. As a result, 060 * {@link ConfigurationSection#contains(java.lang.String)} will always 061 * return the same value as {@link 062 * ConfigurationSection#isSet(java.lang.String)}. The default value is 063 * false. 064 * 065 * @return Whether or not defaults are directly copied 066 */ 067 public boolean copyDefaults() { 068 return copyDefaults; 069 } 070 071 /** 072 * Sets if the {@link Configuration} should copy values from its default 073 * {@link Configuration} directly. 074 * <p> 075 * If this is true, all values in the default Configuration will be 076 * directly copied, making it impossible to distinguish between values 077 * that were set and values that are provided by default. As a result, 078 * {@link ConfigurationSection#contains(java.lang.String)} will always 079 * return the same value as {@link 080 * ConfigurationSection#isSet(java.lang.String)}. The default value is 081 * false. 082 * 083 * @param value Whether or not defaults are directly copied 084 * @return This object, for chaining 085 */ 086 public ConfigurationOptions copyDefaults(boolean value) { 087 this.copyDefaults = value; 088 return this; 089 } 090 }