InventivetalentDev / ReflectionHelper

API for accessing various classes and their members using reflection. (Specifically for Minecraft)
https://www.spigotmc.org/resources/api-reflectionhelper.19241/
MIT License
36 stars 26 forks source link

Minecraft.Version.getVersion() throws NullPointer exception #47

Open Hyuchiha opened 3 years ago

Hyuchiha commented 3 years ago

Im using the latest version of ReflectionHelper(1.15.2-SNAPSHOT) and Spigot 1.12.2, using Minecraft.Version.getVersion() throws a NullPointerException

Caused by: java.lang.RuntimeException: Failed to get version at org.inventivetalent.reflection.minecraft.MinecraftVersion.<clinit>(MinecraftVersion.java:16) ~[?:?] ... 18 more Caused by: java.lang.NullPointerException at org.inventivetalent.reflection.minecraft.Minecraft$Version.values(Minecraft.java:94) ~[?:?] at org.inventivetalent.reflection.minecraft.MinecraftVersion.getVersion(MinecraftVersion.java:93) ~[?:?] at org.inventivetalent.reflection.minecraft.MinecraftVersion.<clinit>(MinecraftVersion.java:14) ~[?:?]

Additional context The function is called in onEnable function as it needed to load some things, in the version 1.14 of ReflectionHelper this doesnt happen

Hyuchiha commented 3 years ago

Apparently is caused because the enum is not initialized (Java 11 things), i make it work calling MinecraftVersion.getVersion() at start and before the call to Minecraft.Version.getVersion(), weird