Creating config file claims null directory

thanks :slight_smile: I had gotten that config setup from Simple plugin configuration tutorial? - #3 by intronate67

Now I’m getting an error about not being able to inject something though :S

  1. Error injecting constructor, java.lang.NullPointerException
    at com.patey07.NTCCore.NTCCore.(NTCCore.java:38)
    at org.spongepowered.common.guice.SpongePluginGuiceModule.configure(SpongePluginGuiceModule.java:68)
    while locating com.patey07.NTCCore.NTCCore

1 error
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1025) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at org.spongepowered.mod.plugin.SpongeModPluginContainer.constructMod(SpongeModPluginContainer.java:288) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_141]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_141]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_141]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_141]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.10.2.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) ~[LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) ~[LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_141]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_141]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_141]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_141]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[minecraft_server.1.10.2.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[minecraft_server.1.10.2.jar:?]
at net.minecraftforge.fml.common.LoadController.redirect$onPost$zzb000(LoadController.java:561) ~[LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:549) [Loader.class:?]
at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:97) [FMLServerHandler.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:328) [FMLCommonHandler.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:121) [ld.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:431) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_141]
Caused by: java.lang.NullPointerException
at com.patey07.NTCCore.NTCCore.(NTCCore.java:48) ~[NTCCore.class:?]
at com.patey07.NTCCore.NTCCore$$FastClassByGuice$$1c96668d.newInstance() ~[$ReflectUtils.class:?]
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012) ~[spongeforge-1.10.2-2281-5.2.0-BETA-2433.jar:1.10.2-2281-5.2.0-BETA-2433]
… 30 more

entire main class code:

@Plugin(id = “ntccore”, name = “NTC-Core”, version = “0.0.1”)
public class NTCCore {

private static NTCCore instance;
public static NTCCore getInstance() {
    return instance;
}

private final Logger logger;
private final Game game;

public Logger getLogger() {
return this.logger;
}

@Inject
public NTCCore(Logger logger, Game game) {
    instance = this;
    this.logger = logger;
    this.game = game;
}

@Inject
@ConfigDir(sharedRoot = false)
private Path configDir;
private Path configFile = configDir.resolve("config.conf");

private ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(configFile).build();
private CommentedConfigurationNode configNode;
@Listener
public void onPreInit(GamePreInitializationEvent e){
    configsetup();
}

public void configsetup(){
    if(!Files.exists(configDir)){
        try{
            Files.createDirectories(configDir);
        }catch(IOException io){
            io.printStackTrace();
        }
    }
    
    if(!Files.exists(configFile)){
        try{
            Files.createFile(configFile);
        
        }catch(IOException e){
            e.printStackTrace();
        }
    }else{
        load();
    }
}
//Loads config file if it already exists
public void load(){
    try{
        configNode = configLoader.load();
    }catch(IOException e){
        e.printStackTrace();
    }
}
//And obviously saves config whenever needed.
public void save(){
    try{
        configLoader.save(configNode);
    }catch(IOException e){
        e.printStackTrace();
    }
}

@Listener
public void onServerStart(GameStartedServerEvent event) {
	getLogger().info("NTC-Core module initialized!");
}

@Listener
public void onInitialize(GameInitializationEvent event) {
	RegisterEvents();
}

public void RegisterEvents() {
	game.getEventManager().registerListeners(this, new PlayerJoin(this));
}

public Path getConfigDir(){
    return configDir;
}

public CommentedConfigurationNode get(){
    return configNode;
}

}