// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.universe.world;

import java.io.IOException;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
import java.nio.file.Path;

public interface WorldConfigProvider
{
    @Nonnull
    default CompletableFuture<WorldConfig> load(@Nonnull final Path savePath, final String name) {
        final Path oldPath = savePath.resolve("config.bson");
        final Path path = savePath.resolve("config.json");
        if (Files.exists(oldPath, new LinkOption[0]) && !Files.exists(path, new LinkOption[0])) {
            try {
                Files.move(oldPath, path, new CopyOption[0]);
            }
            catch (final IOException ex) {}
        }
        return WorldConfig.load(path);
    }
    
    @Nonnull
    default CompletableFuture<Void> save(@Nonnull final Path savePath, final WorldConfig config, final World world) {
        return WorldConfig.save(savePath.resolve("config.json"), config);
    }
    
    public static class Default implements WorldConfigProvider
    {
    }
}
