Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the self-user state was not being loaded correctly in CyberLevels. The promotion path in UserManagerImpl#finishUserLoad was reusing the stale in-memory existing user instead of the freshly loaded result.user, which could leave outdated data in the cache. The level command now also guards against a null self-user and a null player. Version is bumped to 1.2.9.
Changes:
- build.gradle.kts: bump version from 1.2.8 to 1.2.9
- UserManagerImpl#finishUserLoad: when promoting a cached user to online, use the freshly loaded
result.userinstead of the staleexistinginstance - CLVCommand#sendLevelInfo: early-return when
playeris null and emit aplayerNotFoundmessage when the self-user lookup returns null
Reviewed changes
- Medium
src/main/java/com/bitaspire/cyberlevels/command/CLVCommand.java- Self-user lookup may still race with async load
sendLevelInfonow treats a nulluseras 'player not found', butuserManager().getUser(player)for the executing player can legitimately return null while the self-user data is still being loaded asynchronously. SendingplayerNotFoundin that case is misleading and will spam players on first join / after reload. Consider either (a) triggering a load and returning a transient message, or (b) only treating null as 'not found' when the lookup is known synchronous, and otherwise returning a 'loading, try again' message. - Low
src/main/java/com/bitaspire/cyberlevels/command/CLVCommand.java- Inconsistent null handling forplayer
sendLevelInfonow silently returnstruewhenplayeris null. Other helpers in this command typically log or surface a clearer error. If this method is only ever called with a non-null player (e.g. from aCommandSendercast), the guard is dead code; if it can be null, returningtrueswallows the failure. Either drop the guard or returnfalse/log. - Low
src/main/java/com/bitaspire/cyberlevels/UserManagerImpl.java- Promotion path still dropsexistingstate on mismatch
Switching fromexistingtoresult.useris correct for fixing stale data, but ifresult.useris a freshly constructed offline user that lacks transient fields the previousexistingcarried (e.g. session-only flags), those will be lost. Worth confirmingtoOnlineUseris fed a fully-populated user and that no in-memory deltas onexistingneed to be merged in.
Reviewed 3 changed files in this pull request and generated 1 inline comment.
Generated by pull_request.opened.
| } | ||
|
|
||
| private boolean sendLevelInfo(Player player) { | ||
| if (player == null) return true; |
There was a problem hiding this comment.
Returning true on a null player silently swallows the failure. If this branch is unreachable, drop the guard; otherwise return false so the failure is visible.
| if (player == null) return true; | |
| if (player == null) return false; |
There was a problem hiding this comment.
Partially valid, but I would not change this to false. This command handles its own feedback and normally returns true; returning false would only delegate to Bukkit usage, which is not useful here. The real fix is to avoid calling sendLevelInfo with a null player, e.g. make the purge miss path send player-not-found for console instead.
Klema4
left a comment
There was a problem hiding this comment.
I'll approve it soon, I just want to know this one pending comment
| } | ||
|
|
||
| private boolean sendLevelInfo(Player player) { | ||
| if (player == null) return true; |
Summary
Commits
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.