Possible bug in teleportAsync #26

Closed
opened 2023-04-01 15:07:20 +02:00 by cavallium · 2 comments
cavallium commented 2023-04-01 15:07:20 +02:00 (Migrated from github.com)

Stack trace

java.lang.IllegalStateException: Player is already removed from player chunk loader
      at io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.removePlayer(RegionizedPlayerChunkLoader.java:158) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ChunkMap.removePlayerFromDistanceMaps(ChunkMap.java:213) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ChunkMap.updatePlayerStatus(ChunkMap.java:1016) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ChunkMap.removeEntity(ChunkMap.java:1103) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ServerChunkCache.removeEntity(ServerChunkCache.java:871) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ServerLevel$EntityCallbacks.onTrackingEnd(ServerLevel.java:2837) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ServerLevel$EntityCallbacks.onTrackingEnd(ServerLevel.java:2715) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.chunk.system.entity.EntityLookup.entityStatusChange(EntityLookup.java:288) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.chunk.system.entity.EntityLookup$EntityCallback.onRemove(EntityLookup.java:848) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.world.entity.Entity.setRemoved(Entity.java:5328) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.world.entity.Entity.remove(Entity.java:693) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.world.entity.LivingEntity.remove(LivingEntity.java:745) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.world.entity.player.Player.remove(Player.java:1496) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ServerLevel.removePlayerImmediately(ServerLevel.java:1701) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ServerPlayer.transformForAsyncTeleport(ServerPlayer.java:1396) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.level.ServerPlayer.transformForAsyncTeleport(ServerPlayer.java:188) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.world.entity.Entity.teleportAsync(Entity.java:3780) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity.lambda$teleportAsync$1(CraftEntity.java:1336) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity.teleportAsync(CraftEntity.java:1351) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at org.bukkit.entity.Entity.teleportAsync(Entity.java:199) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?]
      ...
      ...
      ...
      at fr.xephi.authme.listener.PlayerListener.onPlayerJoin(PlayerListener.java:184) ~[AuthMe-5.6.0-SNAPSHOT.jar:?]
      at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor51.execute(Unknown Source) ~[?:?]
      at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?]
      at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:git-Folia-"7072994"]
      at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?]
      at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?]
      at net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:404) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.network.ServerLoginPacketListenerImpl.lambda$handleAcceptedLogin$1(ServerLoginPacketListenerImpl.java:204) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.threadedregions.RegionizedTaskQueue$PrioritisedQueue$ChunkBasedPriorityTask.executeInternal(RegionizedTaskQueue.java:489) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.threadedregions.RegionizedTaskQueue$PrioritisedQueue.executeTask(RegionizedTaskQueue.java:419) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.threadedregions.RegionizedTaskQueue$RegionTaskQueueData.drainTasks(RegionizedTaskQueue.java:248) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1523) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:316) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:383) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.19.4.jar:git-Folia-"7072994"]
      at java.lang.Thread.run(Thread.java:1589) ~[?:?]

Plugin and Datapack List

AuthMeReloaded

Actions to reproduce (if known)

  1. Call Bukkit.isOwnedByCurrentRegion(entity)
  2. If it returns true, call .teleportAsync(entity, loc)

Folia version

Latest commit, 7072994

Other

teleportAsync() documentation tells that it should return a future with the result of the teleport, it shouldn't throw an exception if the teleport is not possible.

### Stack trace ```java java.lang.IllegalStateException: Player is already removed from player chunk loader at io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.removePlayer(RegionizedPlayerChunkLoader.java:158) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ChunkMap.removePlayerFromDistanceMaps(ChunkMap.java:213) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ChunkMap.updatePlayerStatus(ChunkMap.java:1016) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ChunkMap.removeEntity(ChunkMap.java:1103) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ServerChunkCache.removeEntity(ServerChunkCache.java:871) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ServerLevel$EntityCallbacks.onTrackingEnd(ServerLevel.java:2837) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ServerLevel$EntityCallbacks.onTrackingEnd(ServerLevel.java:2715) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.chunk.system.entity.EntityLookup.entityStatusChange(EntityLookup.java:288) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.chunk.system.entity.EntityLookup$EntityCallback.onRemove(EntityLookup.java:848) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.world.entity.Entity.setRemoved(Entity.java:5328) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.world.entity.Entity.remove(Entity.java:693) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.world.entity.LivingEntity.remove(LivingEntity.java:745) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.world.entity.player.Player.remove(Player.java:1496) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ServerLevel.removePlayerImmediately(ServerLevel.java:1701) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ServerPlayer.transformForAsyncTeleport(ServerPlayer.java:1396) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.level.ServerPlayer.transformForAsyncTeleport(ServerPlayer.java:188) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.world.entity.Entity.teleportAsync(Entity.java:3780) ~[folia-1.19.4.jar:git-Folia-"7072994"] at org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity.lambda$teleportAsync$1(CraftEntity.java:1336) ~[folia-1.19.4.jar:git-Folia-"7072994"] at org.bukkit.craftbukkit.v1_19_R3.entity.CraftEntity.teleportAsync(CraftEntity.java:1351) ~[folia-1.19.4.jar:git-Folia-"7072994"] at org.bukkit.entity.Entity.teleportAsync(Entity.java:199) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?] ... ... ... at fr.xephi.authme.listener.PlayerListener.onPlayerJoin(PlayerListener.java:184) ~[AuthMe-5.6.0-SNAPSHOT.jar:?] at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor51.execute(Unknown Source) ~[?:?] at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?] at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:77) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:git-Folia-"7072994"] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?] at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[folia-1.19.4.jar:git-Folia-"7072994"] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[folia-api-1.19.4-R0.1-SNAPSHOT.jar:?] at net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:404) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.network.ServerLoginPacketListenerImpl.lambda$handleAcceptedLogin$1(ServerLoginPacketListenerImpl.java:204) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.threadedregions.RegionizedTaskQueue$PrioritisedQueue$ChunkBasedPriorityTask.executeInternal(RegionizedTaskQueue.java:489) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.threadedregions.RegionizedTaskQueue$PrioritisedQueue.executeTask(RegionizedTaskQueue.java:419) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.threadedregions.RegionizedTaskQueue$RegionTaskQueueData.drainTasks(RegionizedTaskQueue.java:248) ~[folia-1.19.4.jar:git-Folia-"7072994"] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1523) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.threadedregions.TickRegions$ConcreteRegionTickHandle.tickRegion(TickRegions.java:316) ~[folia-1.19.4.jar:git-Folia-"7072994"] at io.papermc.paper.threadedregions.TickRegionScheduler$RegionScheduleHandle.runTick(TickRegionScheduler.java:383) ~[folia-1.19.4.jar:git-Folia-"7072994"] at ca.spottedleaf.concurrentutil.scheduler.SchedulerThreadPool$TickThreadRunner.run(SchedulerThreadPool.java:525) ~[folia-1.19.4.jar:git-Folia-"7072994"] at java.lang.Thread.run(Thread.java:1589) ~[?:?] ``` ### Plugin and Datapack List AuthMeReloaded ### Actions to reproduce (if known) 1. Call `Bukkit.isOwnedByCurrentRegion(entity)` 2. If it returns true, call `.teleportAsync(entity, loc)` ### Folia version Latest commit, [7072994](https://github.com/PaperMC/Folia/commit/7072994557d6b2f05604613b734e0bbf3b7fa8b1) ### Other teleportAsync() documentation tells that it should return a future with the result of the teleport, it shouldn't throw an exception if the teleport is not possible.
Spottedleaf commented 2023-04-01 16:05:56 +02:00 (Migrated from github.com)

Entity#teleportAsync will remove the entity from the world when teleporting far (and as such will cause the current region to lose ownership of the player), and as a courtesy to other plugins you should not use it inside events. This is expected behavior for PlayerJoinEvent as well, since the player is not in the world yet.

Entity#teleportAsync will remove the entity from the world when teleporting far (and as such will cause the current region to lose ownership of the player), and as a courtesy to other plugins you should not use it inside events. This is expected behavior for PlayerJoinEvent as well, since the player is not in the world yet.
emilyy-dev commented 2023-04-01 17:34:35 +02:00 (Migrated from github.com)

As an amendment, there are other events to proper change the spawn location that isn't PlayerJoin, even when not using Folia, see PlayerSpawnLocation & methods.

As an amendment, there are other events to proper change the spawn location that isn't PlayerJoin, even when not using Folia, see [PlayerSpawnLocation](https://jd.papermc.io/paper/1.19/org/spigotmc/event/player/PlayerSpawnLocationEvent.html) & methods.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Minecraft/Folia#26
No description provided.