@@ -45,16 +45,21 @@ public class YamlDataFile implements UpdatableYamlDataSource
4545
4646 public YamlDataFile (Path directoryPath , String name )
4747 {
48- this (directoryPath , name , Throwable :: printStackTrace );
48+ this (directoryPath , name , Load . NOW );
4949 }
5050
51- public YamlDataFile (Path directoryPath , String name , Consumer <Exception > exceptions )
51+ public YamlDataFile (Path directoryPath , String name , Load load )
52+ {
53+ this (directoryPath , name , load , Throwable ::printStackTrace );
54+ }
55+
56+ public YamlDataFile (Path directoryPath , String name , Load load , Consumer <Exception > exceptions )
5257 {
5358 this .filePath = directoryPath .resolve (name );
5459 this .data = new YamlConfiguration ();
5560 this .exceptions = exceptions ;
5661
57- reload ();
62+ if ( load == Load . NOW ) { reload (); }
5863 }
5964
6065 public Path getFilePath () { return filePath ; }
@@ -81,7 +86,8 @@ public YamlDataFile(Path directoryPath, String name, Consumer<Exception> excepti
8186 protected void reloadsWith (Runnable reloadHandler )
8287 {
8388 this .reloadHandler = Objects .requireNonNull (reloadHandler , "reloadHandler" );
84- reloadHandler .run ();
89+ if (isLoaded ) { reloadHandler .run (); }
90+ else { reload (); } // reload handler is called in reload
8591 }
8692
8793 public final void reload ()
0 commit comments