ProtocolLib

3M Downloads

NPE: Cannot invoke "java.lang.Class.getEnumConstantsShared()" because "klass" is null

aematsubara opened this issue ยท 2 comments

commented

Hi! When trying to send a PLAYER_INFO packet, there's an error when trying to write PlayerInfoAction(s); for some reason, this error doesn't happen that often and when it does, it doesn't seem to affect the game.

** Error **
java.lang.NullPointerException: Cannot invoke "java.lang.Class.getEnumConstantsShared()" because "klass" is null at java.lang.System$2.getEnumConstantsShared(System.java:2284) ~[?:?] at java.util.EnumSet.getUniverse(EnumSet.java:408) ~[?:?] at java.util.EnumSet.noneOf(EnumSet.java:111) ~[?:?] at com.comphenix.protocol.wrappers.EnumWrappers.createEmptyEnumSet(EnumWrappers.java:826) ~[ProtocolLib.jar:?] at com.comphenix.protocol.events.AbstractStructure.lambda$getPlayerInfoActions$1(AbstractStructure.java:650) ~[ProtocolLib.jar:?] at com.comphenix.protocol.wrappers.Converters$6.getGeneric(Converters.java:184) ~[ProtocolLib.jar:?] at com.comphenix.protocol.wrappers.Converters$6.getGeneric(Converters.java:179) ~[ProtocolLib.jar:?] at com.comphenix.protocol.wrappers.Converters$1.getGeneric(Converters.java:47) ~[ProtocolLib.jar:?] at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:331) ~[ProtocolLib.jar:?] at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:295) ~[ProtocolLib.jar:?] at me.matsubara.realisticvillagers.npc.modifier.VisibilityModifier.lambda$queuePlayerListChange$1(VisibilityModifier.java:68) ~[RealisticVillagers-2.0.jar:?] at me.matsubara.realisticvillagers.npc.modifier.NPCModifier.lambda$send$1(NPCModifier.java:91) ~[RealisticVillagers-2.0.jar:?] at java.util.Arrays$ArrayList.forEach(Arrays.java:4204) ~[?:?] at me.matsubara.realisticvillagers.npc.modifier.NPCModifier.send(NPCModifier.java:87) ~[RealisticVillagers-2.0.jar:?] at me.matsubara.realisticvillagers.npc.modifier.NPCModifier.send(NPCModifier.java:103) ~[RealisticVillagers-2.0.jar:?] at me.matsubara.realisticvillagers.npc.NPC.show(NPC.java:123) ~[RealisticVillagers-2.0.jar:?] at me.matsubara.realisticvillagers.npc.NPCPool.lambda$npcTick$0(NPCPool.java:195) ~[RealisticVillagers-2.0.jar:?] at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.3.jar:git-Paper-358] at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[paper-1.19.3.jar:git-Paper-358] at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[paper-1.19.3.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]

This is the line that's causing this error
container.getPlayerInfoActions().write(0, ADD_ACTIONS);
where ADD_ACTIONS is an EnumSet
private static final EnumSet<EnumWrappers.PlayerInfoAction> ADD_ACTIONS = EnumSet.of( EnumWrappers.PlayerInfoAction.ADD_PLAYER, EnumWrappers.PlayerInfoAction.UPDATE_LISTED, EnumWrappers.PlayerInfoAction.UPDATE_LATENCY, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME);

I'm assuming this is an initialization error probably?

Version Info
https://pastebin.com/tjs5XrsY

commented

Same, but on 1.20

commented

Same, but on 1.20

This was fixed for me when that happened by using a dev-build of PL from jenkins