Hello, I am trying to get and read the annotations of a plugin. I loop through all plugins and check if their instance contains the Plugin annotation, but the Plugin annotation doesn’t seem to be present. Why is this?
I have a Sponge plugin installed, and am running on SpongeForge 1127. Note that I am just using the Plugin annotation for testing, it will be replaced with something else in the future.
How odd… The Plugin annotation is retained during runtime. Have you tried other annotations? In addition, I’d like to note that I’ve had success with this from wwithin the plugin class itself, have you tested there?
It does work if I access it from the same plugin (MainClass.class.getAnnotation(Plugin.class) works). I also tried with my custom annotation, but that also fails. My custom annotation is annotated with @Retention(RetentionPolicy.RUNTIME), so it should be available as well.
Wait you should look for Mod.class annotations also, since sponge add forge mods as plugins. And some plugins just have a dummy container, such as sponge api.