package me.galaran.bukkitutils.__utils_project_name__;

import org.bukkit.configuration.file.FileConfiguration;

import java.io.File;
import java.io.IOException;

public class IOUtils {

    public static void saveYml(FileConfiguration config, File file) {
        try {
            config.save(file);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public static void createFileIfNotExists(File file) {
        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    public static void createDirectoryPathIfNotExists(File dir) {
        if (!dir.exists()) {
            dir.mkdirs();
        }
    }
}

@@ -770,10 +770,668 @@
 %7D%0A    %7D%0A
+    %0A    public static File firstAvailableNumberedFile(File dir, String fileName) %7B%0A        if (!dir.exists()) dir.mkdirs();%0A        %0A        String name, dotExt;%0A        int extDelimiterPos = fileName.lastIndexOf('.');%0A        if (extDelimiterPos != -1) %7B%0A            name = fileName.substring(0, extDelimiterPos);%0A            dotExt = fileName.substring(extDelimiterPos);%0A        %7D else %7B%0A            name = fileName;%0A            dotExt = %22%22;%0A        %7D%0A        %0A        int index = 0;%0A        File result;%0A        do %7B%0A            result = new File(dir, name + (++index) + dotExt);%0A        %7D while (result.exists());%0A        %0A        return result;%0A    %7D %0A
 %7D%0A

Add firstAvailableNumberedFile