GH-1370 Fix vanish player collision#1370
Conversation
…nish/VanishInvisibleServiceTest.java
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to disable player collision when they are vanished and restore their previous collision state when they unvanish, backed by a new unit test suite. The reviewer identified a potential memory leak and state inconsistency if a player disconnects while vanished, as their state is never cleaned up. To resolve this, a cleanup method should be exposed and called when a player disconnects.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| Boolean previousCollidableState = this.previousCollidableStates.remove(player.getUniqueId()); | ||
| if (previousCollidableState != null) { | ||
| player.setCollidable(previousCollidableState); | ||
| } | ||
| } |
There was a problem hiding this comment.
Storing the previous collidable state by UUID in a persistent map can lead to a memory leak if a player disconnects while vanished, as their entry is never removed from previousCollidableStates. Additionally, if the player reconnects, their default collision state in the new session or world might differ, but the outdated state from the previous session will be restored when they unvanish.
To prevent this, we should expose a cleanup method to remove the player's state when they disconnect, which should be called from the player quit listener.
Boolean previousCollidableState = this.previousCollidableStates.remove(player.getUniqueId());
if (previousCollidableState != null) {
player.setCollidable(previousCollidableState);
}
}
void removePreviousCollidableState(UUID uuid) {
this.previousCollidableStates.remove(uuid);
}There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 560667bf55
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| void hidePlayer(Player player) { | ||
| this.previousCollidableStates.putIfAbsent(player.getUniqueId(), player.isCollidable()); | ||
| player.setCollidable(false); |
There was a problem hiding this comment.
Restore collision states on shutdown
When the plugin is disabled or reloaded while a player is vanished, PlayerQuitController.onQuit is not involved; EternalCore.disable() only publishes EternalShutdownEvent. This new setCollidable(false) state is player state rather than plugin-scoped hide state, but previousCollidableStates is discarded with the service instance and no shutdown subscriber restores it, so online vanished players can remain non-collidable after a reload with no way for /vanish to restore their original value. Please restore the saved collision states during shutdown.
Useful? React with 👍 / 👎.
No description provided.