Posted January 18, 20187 yr 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 January 18, 20187 yr by DarkEyeDragon Changed state
January 18, 20187 yr 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.
January 18, 20187 yr Author Yeah i find it kinda weird too. But that's how it was done in the example i followed. I'm not really sure how to get the new values.
January 18, 20187 yr I maybe found something, instead of using that syncConfig() method in onConfigChanged event try using ConfigManager.sync(<modid>, Config.Type.INSTANCE);
January 18, 20187 yr Author 8 minutes ago, Terrails said: I maybe found something, instead of using that syncConfig() method in onConfigChanged event try using ConfigManager.sync(<modid>, Config.Type.INSTANCE); That worked. Thanks!
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.