[Enhancement] Add API that lets mods register extensible enums
makamys opened this issue ยท 4 comments
Currently mod developers who extend enums in their mods are required to either instruct their users to add entries to lwjgl3ify's extensibleEnums
list, or get their entries merged into lwjgl3ify's built-in list, then tell users to regenerate their config, a far from ideal solution.
It would be nice if there was an API that let mods declare classes that should be added to the list at runtime.
Would an annotation published in a separate api package be an ok solution? Currently you can do it by doing something like public enum MyEnum implements IExtensibleEnum {}
using @Optional
to strip the interface when lwjgl3ify is not loaded, but it's a bit clunky
I should've been more specific. I meant registering enum classes by name, for example vanilla classes, not necessarily ones that are added by the mod.
Something like a registerExtensibleEnum(String className)
method that adds entries to the list returned by Config#getExtensibleEnums()
. Calling this before the target enum class is loaded would be the responsibility of the caller.
Ah ok this makes sense, I can probably just make the Config list an ArrayList (or actually it should be a Set) and add a public method for modifying it so you can just call it via reflection as needed