Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • 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.

I maybe found something, instead of using that syncConfig() method in onConfigChanged event try using 

ConfigManager.sync(<modid>, Config.Type.INSTANCE);

 

  • 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.