CoFH/CoFHCore — pull request #60 by tgame14 (2014-09-03 12:21:53+00:00)
Title: @NConfig and @MConfig annotation

This pull request adds 1 feature as discussed with @skyboy on IRC.

the Annotation NConfig and MConfig

NConfig is an annotation that is namespace based.

implemented as such:
In postinit of your mod class, add

ConfigManager.Instance().nconfigure(Configuration configuration, String namespace);

With doing that, all files in the package and sub-packages of the given namespace which contain
non-final static fields will be put into the configuration file automatically and will read it
on initialization.

keep in mind, putting the piece of code in postinit is not required, but has to be after preinit. it is still recommended to put it in postinit.

MConfig is not implemented. as @skyboy has a method he wanted to do himself, yet im putting it in the PR for orders sake of this annotation system. in short. MConfig will contain an argument for IUpdateableMod interface (likely through a key or string, as annotations don't take objects) and through that, it will be put into that mods Configuration object. I myself recommend an inheriting Interface named IConfigurableMod and have that contain a method to handle each annotation as wanted.

public interface IConfigurableMod extends IUpdateableMod
{
void handleConfig (MConfig annotation, Field field)
}

and in addition simply grab the mod instance from the FML Mod list and check instanceof IConfigurableObject, or on the contrary just keeping a registry of all IUpdateableMod entries.

Most importantly, point of these annotations are to be as simple to use as possible, and the heavy lifting should be done by CoFHCore. on the side of MConfig i am not sure what exactly is wanted to be done, so thats up to you.