package complexciv.spongecassandra;

import com.google.inject.Inject;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.loader.ConfigurationLoader;
import org.slf4j.Logger;
import org.spongepowered.api.Game;
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
import org.spongepowered.api.event.game.state.GameStoppingServerEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.config.DefaultConfig;
import org.spongepowered.api.event.Listener;

@Plugin(id = PomData.ARTIFACT_ID, name = PomData.NAME, version = PomData.VERSION)
public class SpongeCassandra {

    @Inject
    private Logger logger;

    @Inject
    @DefaultConfig(sharedRoot = true)
    private ConfigurationLoader<CommentedConfigurationNode> configLoader;

    @Inject
    private Game game;

    @Listener
    public void onPreInit(GamePreInitializationEvent event) {
        // Perform initialization tasks here
    }

    @Listener
    public void disable(GameStoppingServerEvent event) {
        // Perform shutdown tasks here
    }
}

@@ -63,16 +63,68 @@
 Inject;%0A
+import ninja.leaping.configurate.ConfigurationNode;%0A
 import n
@@ -178,32 +178,32 @@
 figurationNode;%0A
-
 import ninja.lea
@@ -307,16 +307,112 @@
 i.Game;%0A
+import org.spongepowered.api.config.DefaultConfig;%0Aimport org.spongepowered.api.event.Listener;%0A
 import o
@@ -596,102 +596,86 @@
 in;%0A
+%0A
 import 
-org.spongepowered.api.config.DefaultConfig;%0Aimport org.spongepowered.api.event.Listener
+java.io.File;%0Aimport java.io.IOException;%0Aimport java.util.Collections
 ;%0A%0A@
@@ -823,24 +823,108 @@
 er logger;%0A%0A
+    @Inject%0A    @DefaultConfig(sharedRoot = false)%0A    private File defaultConfig;%0A%0A
     @Inject%0A
@@ -1032,24 +1032,70 @@
 figLoader;%0A%0A
+    private ConfigurationNode config = null;%0A%0A
     @Inject%0A
@@ -1206,44 +1206,21 @@
     
-// Perform initialization tasks here
+initConfig();
 %0A   
@@ -1286,32 +1286,32 @@
 rEvent event) %7B%0A
-
         // Perfo
@@ -1338,11 +1338,506 @@
 re%0A    %7D
+%0A%0A    private void initConfig() %7B%0A        try %7B%0A            config = configLoader.load();%0A%0A            if (!defaultConfig.exists()) %7B%0A                config.getNode(%22cassandra%22, %22contact-points%22).setValue(Collections.singletonList(%220.0.0.0%22));%0A                config.getNode(%22cassandra%22, %22port%22).setValue(9160);%0A                configLoader.save(config);%0A            %7D%0A        %7D catch (IOException e) %7B%0A            logger.warn(%22Main config could not be loaded/created/changed!%22);%0A        %7D%0A    %7D
 %0A%7D%0A

Create Config