@@ -38,7 +38,6 @@ public class YamlDataFile implements UpdatableYamlDataSource
3838 private final Consumer <Exception > exceptions ;
3939
4040 private int reloads = 0 ;
41- private boolean isLoaded = false ;
4241 private boolean isUpdated = false ;
4342 private boolean isNewlyCreated = false ;
4443 private @ NullOr Exception invalidReason = null ;
@@ -68,8 +67,6 @@ public YamlDataFile(Path directoryPath, String name, Load load, Consumer<Excepti
6867 @ Override
6968 public YamlConfiguration data () { return data ; }
7069
71- public boolean isLoaded () { return isLoaded ; }
72-
7370 @ Override
7471 public boolean isUpdated () { return isUpdated ; }
7572
@@ -89,8 +86,8 @@ protected void reloadsWith(Runnable reloadHandler)
8986 Objects .requireNonNull (reloadHandler , "reloadHandler" );
9087 this .reloadHandler = reloadHandler ;
9188
92- // Only run if already loaded
93- if (isLoaded ) { reloadHandler .run (); }
89+ // Run right away if config data has already loaded at least once
90+ if (reloads > 0 ) { reloadHandler .run (); }
9491 }
9592
9693 public final void reload ()
@@ -103,19 +100,13 @@ public final void reload()
103100 try
104101 {
105102 data .loadFromString (Files .readString (filePath ));
106- isLoaded = true ;
107103 }
108104 catch (InvalidConfigurationException | IOException | RuntimeException e )
109105 {
110106 invalidReason = e ;
111107 exceptions .accept (e );
112108 }
113109 }
114- else
115- {
116- // Nothing to load, so... it's loaded!
117- isLoaded = true ;
118- }
119110
120111 if (reloadHandler != null ) { reloadHandler .run (); }
121112 }
@@ -209,6 +200,8 @@ public void migrateValues(List<YamlValue<?>> values, ConfigurationSection existi
209200
210201 public void defaultValues (List <YamlValue <?>> defaults )
211202 {
203+ boolean fileExists = Files .isRegularFile (filePath );
204+
212205 for (YamlValue <?> value : defaults )
213206 {
214207 migrate (value , data );
@@ -217,7 +210,7 @@ public void defaultValues(List<YamlValue<?>> defaults)
217210 {
218211 // Successfully loaded values from disk already, don't set example value.
219212 // Examples should only be set when the file is created for the first time.
220- if (value instanceof ExampleYamlValue <?> && isLoaded ) { continue ; }
213+ if (value instanceof ExampleYamlValue <?> && fileExists ) { continue ; }
221214
222215 setAsDefaultIfUnset ((DefaultYamlValue <?>) value );
223216 }
0 commit comments