Jump to content

[Solved] Config not saving changes


DarkEyeDragon

Recommended Posts

So i'm trying to save a config using the new annotation system.

However it seems my config doesnt want to update.

 

Event triggers fine. "Config changed" shows up.

public class ConfigChanged{

    @SubscribeEvent
    public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent eventArgs) {
        if(eventArgs.getModID().equals("screenshotuploader")){
            System.out.println("Config changed!");
            ScreenshotMain.syncConfig();
        }
    }

}
public static void syncConfig() {
        overrideDefaultScreenshotKey = config.getBoolean("Override", Configuration.CATEGORY_GENERAL, overrideDefaultScreenshotKey, "Override the default screenshotkey");
        saveScreenshot = config.getBoolean("Save", Configuration.CATEGORY_GENERAL, saveScreenshot, "Set to true if you want your screenshots to save locally and upload to Imgur. Only has effect if Override is set to true");
        if(config.hasChanged())
            config.save();
    }

The method called from the onConfigChanged.

What i tried so far: Moving the config.save() out of the if statement. No effect.
Saving the config first then getting the values again. No effect.

What am i missing here?

Thanks in advance.

 

EDIT:

It get the values fine from the config. It just doesnt change them.

Also my modConfig
 

public class ModConfig{


    @Config.Name("Override")
    @Config.Comment("Override the default screenshotkey")
    public static boolean Override = false;

    @Config.Name("Save")
    @Config.Comment("Set to true if you want your screenshots to save locally and upload to Imgur. Only has effect if Override is set to true")
    public static boolean SaveScreenshots = true;
}

 

Edited by DarkEyeDragon
Changed state
Link to comment
Share on other sites

Did you try replacing the default values with true/false since thats the only thing that I find weird in syncConfig(), since the default is a variable (lets say its false) what if the config value changes to true? The default changes together with it cause its using the same variable to set value to and get default from. I never tried this annotation system but thats the only thing I find weird in that code.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.