ProtocolLib

3M Downloads

EntityUtilities#updateEntity cant deal with two different EntityTrackerEntry impls

MiniDigger opened this issue ยท 0 comments

commented

Using 4.5.0-SNAPSHOT, running 1.13.2

Object trackerEntry = getEntityTrackerEntry(entity.getWorld(), entity.getEntityId());
if (scanPlayersMethod == null) {
scanPlayersMethod = findScanPlayers(trackerEntry.getClass());
}
scanPlayersMethod.invoke(trackerEntry, nmsPlayers);

this code gets the entity tracker entry of an entity and caches the "track" method.

the issue is, that both citizens and protocolsupport have their own entity tracker impls (https://github.com/CitizensDev/Citizens2/blob/master/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java and https://github.com/ProtocolSupport/ProtocolSupport/blob/master/src/protocolsupport/zplatform/impl/spigot/entitytracker/SpigotEntityTrackerEntry.java )

caching the method then breaks, because the cached method only applies to one of the two impls, leading to this exception:

java.lang.IllegalArgumentException: object is not an instance of declaring class
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
	at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:16) ~[?:?]
	at com.comphenix.protocol.injector.EntityUtilities.updateEntity(EntityUtilities.java:80) ~[?:?]
	at com.comphenix.protocol.injector.PacketFilterManager.updateEntity(PacketFilterManager.java:927) ~[?:?]
	at com.dyescape.--------------(---------.java:59) ~[?:?]
	at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftTask.run(CraftTask.java:84) ~[dyescapepaper-server.jar:git-DyescapePaper-acbff0e]
	at org.bukkit.craftbukkit.v1_13_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:449) ~[dyescapepaper-server.jar:git-DyescapePaper-acbff0e]
	at net.minecraft.server.v1_13_R2.MinecraftServer.b(MinecraftServer.java:1012) ~[dyescapepaper-server.jar:git-DyescapePaper-acbff0e]
	at net.minecraft.server.v1_13_R2.DedicatedServer.b(DedicatedServer.java:439) ~[dyescapepaper-server.jar:git-DyescapePaper-acbff0e]
	at net.minecraft.server.v1_13_R2.MinecraftServer.a(MinecraftServer.java:942) ~[dyescapepaper-server.jar:git-DyescapePaper-acbff0e]
	at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:838) ~[dyescapepaper-server.jar:git-DyescapePaper-acbff0e]
	at java.lang.Thread.run(Thread.java:834) [?:?]

https://i.imgur.com/j06CY9e.png

I am not too sure how to fix this. Not caching isn't really an option and a map for class just feels meh, any other ideas?