Class ConfigFile
java.lang.Object
fr.robie.machineengine.api.config.ConfigFile
- All Implemented Interfaces:
ConfigValues
A YAML settings file read through typed
ConfigKeys.
Loading never fails the plugin and never loses what the owner wrote:
- a missing file is created from the
ConfigSpec, with its header and comments; - a missing key is added with its default and comment, and the file is saved;
- an invalid value logs a warning and uses the default (a
clampednumber out of range uses the nearest bound); the file keeps the owner's text; - keys the spec does not know are kept;
- a file that cannot be parsed is not touched: defaults are used (or, on a reload, the old values).
-
Method Summary
Modifier and TypeMethodDescription@NotNull Pathfile()<T> TThe value ofkey: the file's if it is valid, else the key's default.static @NotNull ConfigFileload(@NotNull Path file, @NotNull ConfigSpec spec, @NotNull Logger logger) Loadsfile, creating or completing it.static @NotNull ConfigFileload(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String fileName, @NotNull ConfigSpec spec) LoadsfileNamein the plugin's data folder.@NotNull ConfigLoadResultreload()Reads the file again; restart-only keys keep their value.@NotNull ConfigSpecspec()
-
Method Details
-
load
@NotNull public static @NotNull ConfigFile load(@NotNull @NotNull Path file, @NotNull @NotNull ConfigSpec spec, @NotNull @NotNull Logger logger) Loadsfile, creating or completing it. -
load
@NotNull public static @NotNull ConfigFile load(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String fileName, @NotNull @NotNull ConfigSpec spec) LoadsfileNamein the plugin's data folder. -
get
Description copied from interface:ConfigValuesThe value ofkey: the file's if it is valid, else the key's default.- Specified by:
getin interfaceConfigValues
-
reload
Reads the file again; restart-only keys keep their value. Also adds keys that went missing. -
file
-
spec
-