Skip to content

Refactor GeyserSession and GeyserImpl (Extract Method)#6235

Open
MansiPatil21 wants to merge 1 commit intoGeyserMC:masterfrom
MansiPatil21:refactor/session-impl-cleanup
Open

Refactor GeyserSession and GeyserImpl (Extract Method)#6235
MansiPatil21 wants to merge 1 commit intoGeyserMC:masterfrom
MansiPatil21:refactor/session-impl-cleanup

Conversation

@MansiPatil21
Copy link

This PR performs structural refactoring in two of the largest classes: GeyserSession and GeyserImpl. The goal is to address the Large Class and Long Method code smells by extracting logically grouped functionality into smaller helper methods while preserving existing behavior.
Changes made:
GeyserImpl
Extracted the deeply nested metrics initialization into setupMetrics().
Extracted authentication chain loading into loadSavedAuthChains().
Both were previously embedded inside startInstance().
GeyserSession
Extracted initialization logic from connect() into smaller helper methods:
sendRegistryDefinitions()
sendInitialPlayerState()
sendInitialGameRules()
Refactored the large startGame() method by splitting it into:
buildStartGamePacket()
configureExperiments()
Extracted spectator ability layer construction from sendAdventureSettings() into buildSpectatorAbilityLayer().
All changes are behavior-preserving structural extractions intended to improve code readability, maintainability, and separation of concerns.

Addressed Large Class / Long Method smells by extracting:
- `startGame()` logic to `buildStartGamePacket()` and `configureExperiments()`
- `connect()` logic to `sendRegistryDefinitions()`, `sendInitialPlayerState()`, `sendInitialGameRules()`
- `sendAdventureSettings()` spectator layer to `buildSpectatorAbilityLayer()`
- `startInstance()` metrics and auth logic to `setupMetrics()` and `loadSavedAuthChains()`
Copilot AI review requested due to automatic review settings March 12, 2026 17:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Structural refactor of two core, high-complexity classes (GeyserSession and GeyserImpl) by extracting logically grouped blocks into helper methods to reduce long-method/large-class complexity while preserving existing behavior.

Changes:

  • GeyserSession: extracted connection setup packet sends into sendRegistryDefinitions(), sendInitialPlayerState(), and sendInitialGameRules().
  • GeyserSession: split startGame() responsibilities via buildStartGamePacket() and configureExperiments(), and extracted spectator ability-layer creation into buildSpectatorAbilityLayer().
  • GeyserImpl: extracted metrics initialization into setupMetrics() and saved auth-chain loading into loadSavedAuthChains().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
core/src/main/java/org/geysermc/geyser/session/GeyserSession.java Extracts helper methods from connect(), startGame(), and sendAdventureSettings() to reduce method size and nesting.
core/src/main/java/org/geysermc/geyser/GeyserImpl.java Moves metrics initialization and saved auth-chain loading out of startInstance() into dedicated helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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