Skip to content

Fix NPE during confirmation callback when player flow state is missing (Paper 1.21+)#77

Merged
BenCodez merged 1 commit intoBenCodez:mainfrom
jamjet3:fix/confirmation-npe
Nov 28, 2025
Merged

Fix NPE during confirmation callback when player flow state is missing (Paper 1.21+)#77
BenCodez merged 1 commit intoBenCodez:mainfrom
jamjet3:fix/confirmation-npe

Conversation

@jamjet3
Copy link
Copy Markdown
Contributor

@jamjet3 jamjet3 commented Nov 28, 2025

Summary

This PR fixes a NullPointerException that occurs inside PlayerActionListener$2.failed()
when a confirmation callback attempts to access a flow entry that no longer exists.

Paper 1.21.x tightened async behavior and timing windows, which exposed a race
condition in the confirmation system. If the player cancels, teleports, or otherwise
causes the flow to clear before the callback is executed, the flow.get(uuid) call
returns null, causing an NPE: java.lang.NullPointerException: Cannot invoke "Map$Entry.getValue()"

What this PR changes

  • Adds proper null-checking for flow entries inside the confirmation callback.
  • Gracefully terminates and cleans up the flow instead of throwing exceptions.
  • Prevents console spam and protects scheduled tasks from crashing.
  • Tested on Paper 1.21.10 in a production server environment.

Why it's needed

This fixes active errors triggered by players on modern Paper servers.
The exception does not affect plot integrity but spams console and interrupts
confirmation logic.

This patch is backwards compatible with earlier Spigot/Paper versions.

…n no flow entry exists

This patch resolves a NullPointerException triggered in PlayerActionListener.failed()
when a confirmation callback fires after the associated player flow state has already
been cleared or aborted.

Instead of directly accessing a potentially null Map.Entry from the low map,
the code now performs proper null checks and safely terminates the flow using
fail-safe logic. This prevents scheduled tasks from crashing and avoids repeated
console warnings such as:

  java.lang.NullPointerException: Cannot invoke 'Map.getValue()' because
  the return value of 'HashMap.get(Object)' is null

This issue was triggered when fast player actions caused asynchronous confirmation
callbacks to fire after the flow object was removed (e.g., cancelling, teleporting,
rapid confirm/deny interactions).

Patch tested on Paper 1.21.10.
@BenCodez BenCodez merged commit 33d5137 into BenCodez:main Nov 28, 2025
@jamjet3 jamjet3 deleted the fix/confirmation-npe branch December 1, 2025 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants