Skip to content

GH-1370 Fix vanish player collision#1370

Open
vLuckyyy wants to merge 2 commits into
masterfrom
fix-vanish-collision
Open

GH-1370 Fix vanish player collision#1370
vLuckyyy wants to merge 2 commits into
masterfrom
fix-vanish-collision

Conversation

@vLuckyyy

Copy link
Copy Markdown
Member

No description provided.

@vLuckyyy vLuckyyy requested a review from a team as a code owner June 21, 2026 19:51
@vLuckyyy vLuckyyy changed the title Fix vanish player collision GH-1370 Fix vanish player collision Jun 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +57 to 61
Boolean previousCollidableState = this.previousCollidableStates.remove(player.getUniqueId());
if (previousCollidableState != null) {
player.setCollidable(previousCollidableState);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

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);
    }

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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.

1 participant