lwjgl3ify

lwjgl3ify

1.6k Downloads

[Enhancement] Add API that lets mods register extensible enums

makamys opened this issue ยท 4 comments

commented

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.

commented

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

commented

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.

commented

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

commented

Sounds good. I'd also suggest giving the field an initial value (or initializing it in the setter method) so there's no NPE even if someone uses the class before lwjgl3ify loads its config.