程序包 org.bukkit.configuration.file

# 类 FileConfiguration

java.lang.Object
org.bukkit.configuration.MemorySection
org.bukkit.configuration.MemoryConfiguration
org.bukkit.configuration.file.FileConfiguration

所有已实现的接口:
  `Configuration`, `ConfigurationSection`

直接已知子类:
  `YamlConfiguration`

public abstract class FileConfiguration extends MemoryConfiguration
这是一个实现了 `Configuration` 的配置文件的基类

- ## 字段概要

  ### 从类继承的字段 org.bukkit.configuration.MemoryConfiguration

  `defaults, options`

  ### 从类继承的字段 org.bukkit.configuration.MemorySection

  `map`

- ## 构造器概要

  构造器
  构造器
  说明
  `FileConfiguration()`
  创建一个空的，没有值默认值的 `FileConfiguration`.
  `FileConfiguration(@Nullable Configuration defaults)`
  创建一个空的 `FileConfiguration` 并且使用 `Configuration` 内的所有默认值创建它.

- ## 方法概要

  修饰符和类型
  方法
  说明
  `protected @NotNull String`
  `buildHeader()`
  已过时。
  This method only exists for backwards compatibility.
  `void`
  `load(@NotNull File file)`
  从指定位置加载 `FileConfiguration`
  `void`
  `load(@NotNull Reader reader)`
  Loads this `FileConfiguration` from the specified reader.
  `void`
  `load(@NotNull String file)`
  Loads this `FileConfiguration` from the specified location.
  `abstract void`
  `loadFromString(@NotNull String contents)`
  Loads this `FileConfiguration` from the specified string, as opposed to from file.
  `@NotNull FileConfigurationOptions`
  `options()`
  获取这个 `Configuration` 的 `ConfigurationOptions`.
  `void`
  `save(@NotNull File file)`
  以一个 `FileConfiguration` 调用该方法，将文件储存到指定位置.
  `void`
  `save(@NotNull String file)`
  以一个 `FileConfiguration` 调用该方法，将文件储存到指定位置.
  `abstract @NotNull String`
  `saveToString()`
  将这个 `FileConfiguration` 转化为String对象并且返回

  ### 从类继承的方法 org.bukkit.configuration.MemoryConfiguration

  `addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults`

  ### 从类继承的方法 org.bukkit.configuration.MemorySection

  `contains, contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, setComments, setInlineComments, toString`

  ### 从类继承的方法 java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### 从接口继承的方法 org.bukkit.configuration.ConfigurationSection

  `contains, contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isSet, isString, isVector, set, setComments, setInlineComments`

- ## 构造器详细资料

  - ### FileConfiguration

    public FileConfiguration()
    创建一个空的，没有值默认值的 `FileConfiguration`.

  - ### FileConfiguration

    public FileConfiguration(@Nullable @Nullable Configuration defaults)
    创建一个空的 `FileConfiguration` 并且使用 `Configuration` 内的所有默认值创建它.
    参数:
      `defaults` - 为其创建提供缺省值的Configuration.

- ## 方法详细资料

  - ### save

    public void save(@NotNull @NotNull File file) throws IOException
    以一个 `FileConfiguration` 调用该方法，将文件储存到指定位置.

    如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常

    本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存

    参数:
      `file` - 要储存的文件
    抛出:
      `IOException` - 然后会给出无法创建或者保存的原因.
      `IllegalArgumentException` - 如果文件为空，抛出该异常

  - ### save

    public void save(@NotNull @NotNull String file) throws IOException
    以一个 `FileConfiguration` 调用该方法，将文件储存到指定位置.

    如果你指定储存的这个文件不存在,这个方法会帮你自动创建一个. 如果这个文件存在,那么该方法会把所有未保存的更改直接写入文件 并且直接覆盖原文件. 如果储存或者创建失败,将会抛出一个异常

    本方法会用系统默认的编码储存,不过也有可能用UTF-8出储存

    参数:
      `file` - 要储存的文件
    抛出:
      `IOException` - 然后会给出无法创建或者保存的原因.
      `IllegalArgumentException` - 如果文件为空，泡出该异常

  - ### saveToString

    @NotNull public abstract @NotNull String saveToString()
    将这个 `FileConfiguration` 转化为String对象并且返回
    返回:
      这个FileConfiguration包含的所有String

  - ### load

    public void load(@NotNull @NotNull File file) throws FileNotFoundException, IOException, InvalidConfigurationException
    从指定位置加载 `FileConfiguration`

    All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given file.

    If the file cannot be loaded for any reason, an exception will be thrown.

    参数:
      `file` - File to load from.
    抛出:
      `FileNotFoundException` - Thrown when the given file cannot be opened.
      `IOException` - Thrown when the given file cannot be read.
      `InvalidConfigurationException` - Thrown when the given file is not a valid Configuration.
      `IllegalArgumentException` - Thrown when file is null.

  - ### load

    public void load(@NotNull @NotNull Reader reader) throws IOException, InvalidConfigurationException
    Loads this `FileConfiguration` from the specified reader.

    All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given stream.

    参数:
      `reader` - the reader to load from
    抛出:
      `IOException` - thrown when underlying reader throws an IOException
      `InvalidConfigurationException` - thrown when the reader does not represent a valid Configuration
      `IllegalArgumentException` - thrown when reader is null

  - ### load

    public void load(@NotNull @NotNull String file) throws FileNotFoundException, IOException, InvalidConfigurationException
    Loads this `FileConfiguration` from the specified location.

    All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given file.

    If the file cannot be loaded for any reason, an exception will be thrown.

    参数:
      `file` - File to load from.
    抛出:
      `FileNotFoundException` - Thrown when the given file cannot be opened.
      `IOException` - Thrown when the given file cannot be read.
      `InvalidConfigurationException` - Thrown when the given file is not a valid Configuration.
      `IllegalArgumentException` - Thrown when file is null.

  - ### loadFromString

    public abstract void loadFromString(@NotNull @NotNull String contents) throws InvalidConfigurationException
    Loads this `FileConfiguration` from the specified string, as opposed to from file.

    All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given string.

    If the string is invalid in any way, an exception will be thrown.

    参数:
      `contents` - Contents of a Configuration to load.
    抛出:
      `InvalidConfigurationException` - Thrown if the specified string is invalid.
      `IllegalArgumentException` - Thrown if contents is null.

  - ### buildHeader

    @NotNull @Deprecated protected @NotNull String buildHeader()
    已过时。
    This method only exists for backwards compatibility. It will do nothing and should not be used! Please use `FileConfigurationOptions.getHeader()` instead.
    返回:
      空白字符串

  - ### options

    @NotNull public @NotNull FileConfigurationOptions options()
    从接口复制的说明: `Configuration`
    获取这个 `Configuration` 的 `ConfigurationOptions`.

    如需修改配置,直接修改返回值即可.

    原文: Gets the `ConfigurationOptions` for this `Configuration`.

    All setters through this method are chainable.

    指定者:
      `options` 在接口中 `Configuration`
    覆盖:
      `options` 在类中 `MemoryConfiguration`
    返回:
      这个配置文件的一些配置(格式之类的).