Skip to content

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

Closed

Description

@andrewkm

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.

Activity

  1. added
    status:pendingPending acceptance or closure.
    type:bugIncorrect behavior, not working as intended
    on Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:pendingPending acceptance or closure.type:bugIncorrect behavior, not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions