package io.github.satoshinm.WebSandboxMC.sponge;

import com.google.inject.Inject;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import org.slf4j.Logger;
import org.spongepowered.api.Game;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.config.DefaultConfig;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.plugin.Plugin;

import java.nio.file.Path;

@Plugin(id = "websandboxmc", name = "WebSandboxMC", version = "1.6.0")
public class WebSandboxSpongePlugin {

    @Inject
    private Logger logger;

    @Inject
    @DefaultConfig(sharedRoot = false)
    private Path defaultConfig;

    @Inject
    @DefaultConfig(sharedRoot = false)
    private ConfigurationLoader<CommentedConfigurationNode> configManager;

    @Inject
    @ConfigDir(sharedRoot = false)
    private Path configDir;

    @Inject
    private Game game;

    @Listener
    public void onServerStart(GameStartedServerEvent event) {
        logger.info("WebSandboxMC/Sponge starting");
        logger.info("config path: " + configDir);

        ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setPath(configDir).build();
        ConfigurationNode rootNode = loader.createEmptyNode(ConfigurationOptions.defaults());
        //URL jarConfigFile = Sponge.getAssetManager().getAsset("defaultConfig.conf").get().getURL(); // TODO: can't find get?

    }
}

@@ -440,16 +440,53 @@
 i.Game;%0A
+import org.spongepowered.api.Sponge;%0A
 import o
@@ -524,16 +524,16 @@
 figDir;%0A
-
 import o
@@ -735,16 +735,37 @@
 lugin;%0A%0A
+import java.net.URL;%0A
 import j
@@ -1257,16 +1257,57 @@
  game;%0A%0A
+    private ConfigurationNode rootNode;%0A%0A
     @Lis
@@ -1586,25 +1586,29 @@
 setPath(
-c
+defaultC
 onfig
-Dir
 ).build(
@@ -1618,34 +1618,16 @@
         
-ConfigurationNode 
 rootNode
@@ -1690,136 +1690,8 @@
 ));%0A
-        //URL jarConfigFile = Sponge.getAssetManager().getAsset(%22defaultConfig.conf%22).get().getURL(); // TODO: can't find get?%0A%0A
     

Save configuration rootNode