Bram1903 / AntiHealthIndicator

Enhance fairness with AntiHealthIndicator! Lightweight, async packet spoofing for gameplay integrity. Easy configurable!
https://discord.deathmotion.com
GNU General Public License v3.0
27 stars 5 forks source link

Folia issue: Accessing entity state off owning region's thread #3

Closed HydrolienF closed 5 months ago

HydrolienF commented 5 months ago

Hi, I'm using this plugin on a Folia server and I get an exception. I don't know if it happend only with wolf or not. It might be because isTamed try to access to a player even if player is not in the same region.

java.lang.IllegalStateException: Accessing entity state off owning region's thread
        at io.papermc.paper.util.TickThread.ensureTickThread(TickThread.java:79) ~[folia-1.20.2.jar:git-Folia-"1e5e215"]
        at org.bukkit.craftbukkit.v1_20_R2.entity.CraftWolf.getHandle(CraftWolf.java:35) ~[folia-1.20.2.jar:git-Folia-"1e5e215"]
        at org.bukkit.craftbukkit.v1_20_R2.entity.CraftWolf.getHandle(CraftWolf.java:7) ~[folia-1.20.2.jar:git-Folia-"1e5e215"]
        at org.bukkit.craftbukkit.v1_20_R2.entity.CraftTameableAnimal.isTamed(CraftTameableAnimal.java:60) ~[folia-1.20.2.jar:git-Folia-"1e5e215"]
        at com.deathmotion.antihealthindicator.packetlisteners.abstracts.EntityListenerAbstract.shouldIgnoreWolf(EntityListenerAbstract.java:138) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.packetlisteners.abstracts.EntityListenerAbstract.handlePacket(EntityListenerAbstract.java:69) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.packetlisteners.EntityMetadataListener.onPacketSend(EntityMetadataListener.java:22) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.shaded.com.github.retrooper.packetevents.event.PacketSendEvent.call(PacketSendEvent.java:51) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.shaded.com.github.retrooper.packetevents.event.EventManager.callEvent(EventManager.java:52) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.shaded.com.github.retrooper.packetevents.util.PacketEventsImplHelper.handleClientBoundPacket(PacketEventsImplHelper.java:44) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.shaded.io.github.retrooper.packetevents.injector.handlers.PacketEventsEncoder.handleClientBoundPacket(PacketEventsEncoder.java:82) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.shaded.io.github.retrooper.packetevents.injector.handlers.PacketEventsEncoder.encode(PacketEventsEncoder.java:67) ~[AntiHealthIndicator-1.1.2.jar:?]
        at com.deathmotion.antihealthindicator.shaded.io.github.retrooper.packetevents.injector.handlers.PacketEventsEncoder.encode(PacketEventsEncoder.java:46) ~[AntiHealthIndicator-1.1.2.jar:?]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:90) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
        at com.deathmotion.antihealthindicator.shaded.io.github.retrooper.packetevents.injector.handlers.PacketEventsEncoder.write(PacketEventsEncoder.java:101) ~[AntiHealthIndicator-1.1.2.jar:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
        at ac.grim.grimac.shaded.io.github.retrooper.packetevents.injector.handlers.PacketEventsEncoder.write(PacketEventsEncoder.java:101) ~[grimac-2.3.46.jar:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:113) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:120) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:851) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.handler.codec.MessageToMessageEncoder.writePromiseCombiner(MessageToMessageEncoder.java:140) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:120) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:115) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at me.neznamy.tab.shared.features.injection.NettyPipelineInjector$TabChannelDuplexHandler.write(NettyPipelineInjector.java:134) ~[TAB v4.1.2.jar:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:879) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:120) ~[netty-codec-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:940) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:966) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:934) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1020) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:311) ~[netty-transport-4.1.97.Final.jar:4.1.97.Final]
        at com.comphenix.protocol.injector.netty.channel.NettyChannelProxy.writeAndFlush(NettyChannelProxy.java:227) ~[ProtocolLib.jar:?]
        at com.comphenix.protocol.injector.netty.channel.NettyChannelProxy.writeAndFlush(NettyChannelProxy.java:233) ~[ProtocolLib.jar:?]
        at net.minecraft.network.Connection.doSendPacket(Connection.java:475) ~[?:?]
        at net.minecraft.network.Connection.lambda$sendPacket$10(Connection.java:460) ~[?:?]
        at com.comphenix.protocol.injector.netty.channel.NettyChannelInjector.lambda$proxyAction$7(NettyChannelInjector.java:592) ~[ProtocolLib.jar:?]
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413) ~[netty-transport-classes-epoll-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.97.Final.jar:4.1.97.Final]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]
Bram1903 commented 5 months ago

Hello @HydrolienF,

Thank you for reaching out! This indeed seems like an issue where I am trying to access the state of an entity, that is not on the same region thread!

I will take a look at this somewhere this week, and hopefully push out an update soon! If the console errors are bothering you, or if the feature is currently not working whatsoever, you could set ignore-wolves-enabled to false to prevent it from trying to execute the filter checks that result in the console errors.

Kind regards, Bram

Bram1903 commented 5 months ago

Hi @HydrolienF ,

I wanted to inform you that I've just implemented a fix that addresses the issue you have been experiencing. Could you please take a moment to download the latest snapshot from the link below and let me know if it resolves the problem on your end as well? Based on your feedback, I will proceed with creating a new release later this week. Thank you for your help!

You can access the latest snapshot here: AntiHealthIndicator v1.1.3-SNAPSHOT

Looking forward to hearing from you soon!

Kind regards,
Bram

HydrolienF commented 5 months ago

It fixed it ! Thanks

HydrolienF commented 5 months ago

By the way, having gradle isn't needed to "Compiling Jar From Source". You can run ./gradlew build instead of gradle build and the Gradle wrapper will download gradle if needed. (./gradlew build for Linux, MacOS and Powershell. And .\gradlew build for default Windows terminal)

Bram1903 commented 5 months ago

By the way, having gradle isn't needed to "Compiling Jar From Source". You can run ./gradlew build instead of gradle build and the Gradle wrapper will download gradle if needed.

Hey, thanks for letting me know! I'll give this a shot later today, and otherwise remove Gradle from the requirements!

Bram1903 commented 5 months ago

Hello @HydrolienF,

I updated/improved the build steps in the README. Thanks for mentioning it!

Anyway, I just released a new version on GitHub, SpigotMC, Hanger, and Modrinth. Thanks a lot for bringing this bug to my attention!

Kind regards, Bram

HydrolienF commented 5 months ago

Thanks you for resolving it that quickly !