Basically, my question is the same as this one, except that I have to execute code on every single constant at very specific points in time.
To be more specific, I am attempting to get my game addon to adhere more to object oriented and good design principles and standards. Formerly, we had giant classes containing game object constants, with gigantic static register
methods (eg registerFirearms
, registerArmor
) that would register those objects in their appropriate registries, and then assign them to their global constants.
For example:
public class Items {
public static Item firearm;
public static void register() {
registerFirearms();
}
public static void registerFirearms() {
firearm = new FirearmItem();
Registry.register(firearm);
}
}
At the appropriate time in the game loading process, Items.register();
would get called, and all of the values in that class would be ready to be used throughout the addon.
I'm just not really sure how I should go about storing these object instances without having some monstrous unmaintainable several-thousand-line class.