Skip to content

ViewerEngineListener not tracking disconnects#72

Merged
Tofaa2 merged 2 commits into
Tofaa2:masterfrom
Chubbyduck1:master
Jul 7, 2026
Merged

ViewerEngineListener not tracking disconnects#72
Tofaa2 merged 2 commits into
Tofaa2:masterfrom
Chubbyduck1:master

Conversation

@Chubbyduck1

@Chubbyduck1 Chubbyduck1 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The ViewerEngineListener wouldn't track player disconnects. If the player disconnects without unloading the chunk, Entities would think that the Viewer is still there. Then, when you relog, you can't see the entity until you unload and reload the chunk.

Summary by CodeRabbit

  • Bug Fixes
    • Viewer state is now properly cleared when a user disconnects, removing them from any entities they were viewing.
    • Prevents stale “viewer” information from persisting after logout or unexpected connection loss.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7e4fba54-fa7d-4559-8938-3af6ce2aed65

📥 Commits

Reviewing files that changed from the base of the PR and between 83eead7 and 0d0c44a.

📒 Files selected for processing (1)
  • api/src/main/java/me/tofaa/entitylib/ve/ViewerEngineListener.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/src/main/java/me/tofaa/entitylib/ve/ViewerEngineListener.java

📝 Walkthrough

Walkthrough

ViewerEngineListener adds a disconnect callback that removes a disconnected user from tracked entity viewer lists, with imports for UserDisconnectEvent and UUID.

Changes

Disconnect handling

Layer / File(s) Summary
Disconnect handler and supporting imports
api/src/main/java/me/tofaa/entitylib/ve/ViewerEngineListener.java
Adds onUserDisconnect override that gets the user's UUID, returns early if null, and iterates tracked entities to remove the user as a viewer; adds imports for UserDisconnectEvent and UUID.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding disconnect tracking cleanup in ViewerEngineListener.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/src/main/java/me/tofaa/entitylib/ve/ViewerEngineListener.java`:
- Around line 86-101: Route the disconnect cleanup in
ViewerEngineListener.onUserDisconnect through engine.getExecutor() instead of
mutating viewer state inline. The current loop over engine.getTracked0() and
calls to entity.removeViewer(uniqueId) should be executed on the same serialized
path used by ViewerEngine for tracking work. Keep the null uniqueId guard, but
move the viewer-removal logic into the executor callback so it does not race
with other WrapperEntity mutations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0e6df4cb-9f25-45db-bfaf-672ddbed665d

📥 Commits

Reviewing files that changed from the base of the PR and between ee500f4 and 83eead7.

📒 Files selected for processing (1)
  • api/src/main/java/me/tofaa/entitylib/ve/ViewerEngineListener.java

Comment thread api/src/main/java/me/tofaa/entitylib/ve/ViewerEngineListener.java
@Tofaa2

Tofaa2 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

LGTM

@Tofaa2 Tofaa2 merged commit 03effa4 into Tofaa2:master Jul 7, 2026
2 checks passed
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