Added yaml autosaving

This commit is contained in:
Will FP
2023-12-26 13:33:46 +01:00
parent 0dba790bb2
commit f52a760bbe
7 changed files with 59 additions and 0 deletions

View File

@@ -29,6 +29,22 @@ public interface LoadableConfig extends Config {
*/
void save() throws IOException;
/**
* Save the config asynchronously.
*/
default void saveAsync() {
// This default implementation exists purely for backwards compatibility
// with legacy Config implementations that don't have saveAsync().
// Default eco implementations of Config have saveAsync() implemented.
new Thread(() -> {
try {
this.save();
} catch (IOException e) {
e.printStackTrace();
}
}).start();
}
/**
* Get the config file.
*