NullPointerException on PlayerTeleportEvent when a player disconnects while riding (regression from #2325)

Abierto Apto para principiantes
#2,329 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
backend

Línea de trabajo

Empieza leyendo Session.testMoveTo y el manejo de la salida en PlayerMoveListener.onPlayerQuit; el informe sigue el teletransporte posterior a través de WorldGuardPlayerListener.onPlayerTeleport e identifica que lastValid es null después de la desinicialización. Comprueba las pruebas existentes del movimiento de la sesión, si las hay, y añade cobertura para un teletransporte después de la desinicialización. El trabajo estará terminado cuando desconectarse mientras se monta ya no registre la NullPointerException.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

status:pending type:bug
WorldEdit Version

7.4.7-SNAPSHOT+130688b5d

WorldGuard Version

7.0.22-SNAPSHOT+488d94d6

Platform Version

Paper 26.3-DEV-main@13565bc (current main); also seen on our production server with main@df120fd

Confirmations
  • I am using the most recent Minecraft release.
  • I am using a version of WorldEdit compatible with my Minecraft version.
  • I am using a version of WorldGuard compatible with my Minecraft version.
  • I am using the latest or recommended version of my platform software.
  • I am NOT using a hybrid server, e.g. a server that combines Bukkit and Forge. Examples include Arclight, Mohist, and Cardboard.
  • I am NOT using a fork of WorldEdit, such as FastAsyncWorldEdit (FAWE) or AsyncWorldEdit (AWE)
Bug Description

Since #2325 (d9a8ca5, included in 7.0.21), Session.uninitialize() sets lastValid to null. PlayerMoveListener.onPlayerQuit calls uninitialize(), but when the quitting player is riding a vehicle alone, the server dismounts them afterwards in PlayerList.remove() (stopRiding → dismountTo → teleportTo). That fires a PlayerTeleportEvent, and WorldGuardPlayerListener.onPlayerTeleport → Session.testMoveTo → Locations.isDifferentBlock(lastValid, to) throws a NullPointerException on the null lastValid.

Every disconnect while riding logs this error with a full stack trace (4 times in one afternoon on our server). We saw no gameplay effect: the session is re-initialised on the next join and the vehicle is still saved with the player.

Expected Behavior

No error when a player disconnects while riding: the dismount teleport that follows the quit should be ignored once the session has been uninitialised.

Reproduction Steps
  1. Paper 26.3 with only WorldEdit and WorldGuard installed (default configs, no regions).
  2. Join and ride a vehicle as its only player passenger, e.g. /summon minecraft:oak_boat ~ ~ ~ then /ride <player> mount @e[type=minecraft:oak_boat,limit=1,sort=nearest], or simply board a boat.
  3. Disconnect while still riding.
  4. The console logs Could not pass event PlayerTeleportEvent to WorldGuard with the NullPointerException below. Disconnecting without riding logs nothing.
Optional WorldGuard-Report

No response

Anything Else?

Reproduced on a clean server (only WorldEdit and WorldGuard, Paper main@13565bc) with a bot that rides a boat and disconnects; a control bot that disconnects without riding logs nothing. Stack trace from the clean server (tick frames trimmed):

[23:01:15 INFO]: rider lost connection: Disconnected
[23:01:15 ERROR]: Could not pass event PlayerTeleportEvent to WorldGuard v7.0.22-SNAPSHOT+488d94d6
java.lang.NullPointerException: Cannot invoke "com.sk89q.worldedit.util.Location.getBlockX()" because "a" is null
	at WorldGuard.jar//com.sk89q.worldguard.util.Locations.isDifferentBlock(Locations.java:37) ~[?:?]
	at WorldGuard.jar//com.sk89q.worldguard.session.Session.testMoveTo(Session.java:236) ~[?:?]
	at WorldGuard.jar//com.sk89q.worldguard.session.Session.testMoveTo(Session.java:209) ~[?:?]
	at WorldGuard.jar//com.sk89q.worldguard.bukkit.listener.WorldGuardPlayerListener.onPlayerTeleport(WorldGuardPlayerListener.java:409) ~[?:?]
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:71) ~[paper-api-26.3.local-SNAPSHOT.jar:?]
	at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:52) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:627) ~[paper-api-26.3.local-SNAPSHOT.jar:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.teleport(ServerGamePacketListenerImpl.java:1939) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.server.level.ServerPlayer.teleportTo(ServerPlayer.java:2314) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.server.level.ServerPlayer.dismountTo(ServerPlayer.java:2303) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.world.entity.LivingEntity.dismountVehicle(LivingEntity.java:2973) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.world.entity.LivingEntity.stopRiding(LivingEntity.java:3989) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.world.entity.Entity.stopRiding(Entity.java:3501) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.server.players.PlayerList.remove(PlayerList.java:475) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.server.players.PlayerList.remove(PlayerList.java:435) ~[paper-26.3.jar:26.3-DEV-13565bc]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.removePlayerFromWorld(ServerGamePacketListenerImpl.java:2355) ~[paper-26.3.jar:26.3-DEV-13565bc]

A possible fix: treat an uninitialised session as nothing to test, e.g. return null from Session.testMoveTo while lastValid is null.

Lenguaje dominante
Java
Estrellas
943
Forks
688
Merge medio
3 d 16 h
PR fusionados (30 d)
7

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de EngineHub/WorldGuard

Todos los issues de EngineHub/WorldGuard

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.