load

public static PetBehaviorCatalog load(Path folder, List<String> defaults, Consumer<String> writeDefault, Consumer<String> warn)

Writes the missing defaults through writeDefault, then loads every module in the folder. A module that cannot load is reported through warn and skipped; the rest still load. When part of the folder cannot be read, that is reported and no defaults are written.

writeDefault gets a default's name and must write exactly folder.resolve(name + ".lua"), throwing UncheckedIOException when it cannot. It should write atomically, for example to a temporary file moved into place: a partly written file reads as an owner's edit and is never rewritten.