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

My configuration GUI is not triggering a call of

ConfigChangedEvent.OnConfigChangedEvent

and I don't have the slightest clue why. Everything else is working fine: reading values has no problem, the .cfg is fine, etc. On startup, I sync the configuration, and it works perfectly. Also, as a result of this, any events marked as requiring a restart do not actually require a restart. It's really odd. What could be going wrong?

 

My messy config file (please try not to hurt yourselves while viewing). I am probably doing this VERY wrong, please tell me if so:

public class Config extends GuiConfig {

public static Configuration configFile;

/*
 * Actual configuration values.
 */
    public static String membersList = "";
    public static String mercsList = "";

    public Config(GuiScreen parent) {
        super(parent, new ConfigElement(configFile.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), "MCCTF Mod", false, true, "MCCTF General Config");
    }

    public static void syncConfig() {
        Pattern usernamePattern = Pattern.compile("([A-Za-z0-9_]+((,){1}( )*|$))+?");

    	/*
    	 * Members List
    	 */
    	membersList = configFile.getString("Members List", Configuration.CATEGORY_GENERAL, "username, username, username", "These people will appear on your \"Clan Mate\" list in white.", usernamePattern);
    	System.out.println("membersList: " + membersList);
    	Matcher matcherMembers = usernamePattern.matcher(membersList);
        while (matcherMembers.find()) {
        	System.out.println("Found member match: " + matcherMembers.group().replace(", ", ""));
        	Main.membersList.add(matcherMembers.group().replace(", ", ""));
        }
    	
        /*
         * Merc List
         */
    	mercsList = configFile.getString("Mercs List", Configuration.CATEGORY_GENERAL, "username, username, username", "These people will appear on your \"Clan Mate\" list in gray.", usernamePattern);
    	Matcher matcherMercs = usernamePattern.matcher(mercsList);
        while (matcherMercs.find()) {
        	Main.mercsList.add(matcherMercs.group());
        }
    	
    	if (configFile.hasChanged()) {
    		configFile.save();
    	}
    }
}

 

My GUIFactory:

public class GuiFactory implements IModGuiFactory {

@Override
public void initialize(Minecraft minecraftInstance) {

}

@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
	return Config.class;
}

@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
	return null;
}

@Override
public RuntimeOptionGuiHandler getHandlerFor(
		RuntimeOptionCategoryElement element) {
	return null;
}
}

 

My preInit in Main:

    @EventHandler
    public void preInit(FMLPreInitializationEvent e) {
    	MinecraftForge.EVENT_BUS.register(new Events());
    	FMLCommonHandler.instance().bus().register(new Events());
    	
    	Config.configFile = new Configuration(e.getSuggestedConfigurationFile());
    	Config.syncConfig();
    }

 

My Events class for catching:

@SubscribeEvent
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
	System.out.println("Config changed!");
    if(event.modID.equals("mcctf")) {
       Config.syncConfig();
    }
}

 

Note: "Config changed" isn't even printed after I edit my config. It prints when I edit other mods though.

 

 

  • Author

My friend got this error after I compiled and send it to him:

cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: cpw/mods/fml/client/event/ConfigChangedEvent$OnConfigChangedEvent

My friend got this error after I compiled and send it to him:

cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: cpw/mods/fml/client/event/ConfigChangedEvent$OnConfigChangedEvent

 

This event was just added to Forge, so your friend probably didn't have the correct release of Forge.  I needs to be something like 1133 or later (if I remember correctly, you can check the release notes)

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

My friend got this error after I compiled and send it to him:

cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: cpw/mods/fml/client/event/ConfigChangedEvent$OnConfigChangedEvent

 

This event was just added to Forge, so your friend probably didn't have the correct release of Forge.  I needs to be something like 1133 or later (if I remember correctly, you can check the release notes)

Indeed, this was the problem. I told him to get latest, but he just doesn't listen! :P. Still having the other problem.

What exactly is the other problem?  I read through this agian and I'm not 100% what you are asking help on.

Long time Bukkit & Forge Programmer

Happy to try and help

  • Author

What exactly is the other problem?  I read through this agian and I'm not 100% what you are asking help on.

 

When changes to the config are made, it does not trigger:

ConfigChangedEvent.OnConfigChangedEvent

Like it does with other mods.

  • 2 years later...
On 7/9/2014 at 6:19 PM, NomNuggetNom said:

 

When changes to the config are made, it does not trigger:

 


ConfigChangedEvent.OnConfigChangedEvent
 

 

Like it does with other mods.

 

Hey, I'm having the same issue. Did you ever figure out why?

 

EDIT:

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2126328-trying-to-register-configuration-event

Here I found that when you register the event handler in the Mod class create a new class:

FMLCommonHandler.instance().bus().register(new ConfigurationHandler());

Edited by izzie.llg
EDIT

  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.