Refactor GeyserSession and GeyserImpl (Extract Method)#6235
Open
MansiPatil21 wants to merge 1 commit intoGeyserMC:masterfrom
Open
Refactor GeyserSession and GeyserImpl (Extract Method)#6235MansiPatil21 wants to merge 1 commit intoGeyserMC:masterfrom
MansiPatil21 wants to merge 1 commit intoGeyserMC:masterfrom
Conversation
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()`
Contributor
There was a problem hiding this comment.
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 intosendRegistryDefinitions(),sendInitialPlayerState(), andsendInitialGameRules().GeyserSession: splitstartGame()responsibilities viabuildStartGamePacket()andconfigureExperiments(), and extracted spectator ability-layer creation intobuildSpectatorAbilityLayer().GeyserImpl: extracted metrics initialization intosetupMetrics()and saved auth-chain loading intoloadSavedAuthChains().
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.