NomNuggetNom Posted July 8, 2014 Posted July 8, 2014 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.
NomNuggetNom Posted July 8, 2014 Author Posted July 8, 2014 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
jabelar Posted July 8, 2014 Posted July 8, 2014 On 7/8/2014 at 6:26 PM, NomNuggetNom said: 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/
NomNuggetNom Posted July 8, 2014 Author Posted July 8, 2014 On 7/8/2014 at 6:36 PM, jabelar said: Quote 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! . Still having the other problem.
delpi Posted July 9, 2014 Posted July 9, 2014 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
NomNuggetNom Posted July 9, 2014 Author Posted July 9, 2014 On 7/9/2014 at 5:14 PM, delpi said: 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.
izzie.llg Posted February 28, 2017 Posted February 28, 2017 (edited) On 7/9/2014 at 5:19 PM, NomNuggetNom said: When changes to the config are made, it does not trigger: ConfigChangedEvent.OnConfigChangedEvent Like it does with other mods. Expand 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 February 28, 2017 by izzie.llg EDIT
Recommended Posts