Need help setting up a second...third etc Config file

So I have a Configuration Manager, and right now it’s able to make a single conf file. Its been a while since i played arouund with sponges configuration loader. Can someone help me? here’s the current Main Class

and here’s the ConfigurationManager class

Any help would be much appreciated

you’d… get another File and do the same thing with it.

K… So how would i Name the configs from the configuration Manager?

K so…ignore that…i’ve updated things a bit… and figured out how to name the configs. :smiley: though it’s all being done right now in the main class…i’ll have to figure a way to call it all back to the configurationManager class lol. But thanks so far. Let me know if you have a better way?

Ok please ignore the above…if someone could help me get this to run from another class that would be ideal…i’ve tried wrapping it in a method in another class…however it just errors out. here’s the error log

and here’s the MainClass and the ConfigurationManager2Class class any help to get this to fire in the ConfigurationManager 2 Class would be much appreicated

    //The configuration folder for this plugin
    @Inject
    @ConfigDir(sharedRoot = false)
    private File configDir;

This won’t work in the ConfigurationManager2 class because by default only the main plugin class can use dependency injection.

You could instead pass the configDir in through the constructor of your config class like so:

      ConfigurationManager2 testing = new ConfigurationManager2(this.configDir);

Then assign that to a field

public ConfigurationManager2(File configDir) {
    this.configDir = configDir;
}

You’ll then need to move the configDir injection back to the main class

Perfect! Thank you!
I’ll be able to do that tonight. Then all I need to do is make a configswitchboard class. To change which configuration file is in focus and bam! 65% of the plug in Done! Thank you

Another solution would be to inject the Injector and use getInstance to get the class.

Slight Snag…So there’s no error while compiling…
however once the Game has started loading I get a null at line 76…however the configs load correctly …so I figure it’s somthing to do with the logic. This is literrally the final piece to the complexity of my Plugin so if everyone could bare with me a bit here it all is and here’s the Error log Thank you in advance for any and all help I’m combing through it but I think i need a new set of eyes looking for the null.

int answer = roll.nextInt(100) + 1;

all the errors seem to be here, My guess is that roll is not properly initiated? Also you use this same line quite alot I’d consider making a method for it with the initialization in the same block.

In your HOB class you load the config into a temporary variable, and it doesn’t update the ConfigManager.getInstance() instance.

      DayCounter.config = 1;
      ConfigurationManager testing = new ConfigurationManager();
      testing.ConfigurationManager2(configDir);
      testing.enable();

Try the following:

      DayCounter.config = 1;
      ConfigurationManager.getInstance().ConfigurationManager2(configDir);
      ConfigurationManager.getInstance().enable();
1 Like

Thanks! :slight_smile: I will go ahead and try that once I get my Eclipse up and working tomorrow LOL. Some reason it decided to go belly side up on me LOL