File loader loads data into a list from YAML files.
File loader must extend AbstractFileLoader.
public class MyFileLoader extends AbstractFileLoader<UserCoins> {
@Override
public void load() {
load("users_coins.yml", "users");
}
@Override
public void load(String fileName, String primarySection) {
loadFile(fileName, primarySection, (key, section) ->
this.addObject(section.getObject(key, UserCoins.class)));
}
}
public class MyManyFilesLoader extends AbstractFileLoader<UserCoins> {
@Override
public void load() {
File file = new File(MiniGame.getInstance().getDataFolder(), "users");
File[] files = file.listFiles();
if (files == null) return;
for (File childFile : files) {
load(childFile.getAbsolutePath(), "user");
}
}
@Override
public void load(String fileName, String primarySection) {
File file = new File(fileName);
loadFile(file , primarySection, (key, section) ->
this.addObject(section.getObject(key, UserCoins.class)));
}
}