📂File loader

File loader loads data into a list from YAML files.

File loader must extend AbstractFileLoader.

How to create a loader from a single file?

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)));
    }
}

How to create a loader from a many files?

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)));
    }
}