Refactor: Component structural cleanup (Extract Class, Move Method, Replace Conditional)
This PR introduces a series of structural refactorings to improve code clarity and encapsulation as part of an academic assignment. All changes are strictly structural and do not alter any behavior or packet logic. The project compiles successfully and all tests pass with these changes.
In response to developer feedback advising that larger refactors belong in their own PRs for better review-ability, these 3 structural changes are isolated here:
1. **Extract Class:** Extracted the massive 68-line [Texture](cci:2://file:///Users/mansimanojpatil/Desktop/Pretty/ATSD/MCProtocolLib/protocol/src/main/java/org/geysermc/mcprotocollib/auth/GameProfile.java:379:4-446:5) class (along with `TextureType` and `TextureModel` enums) out of the monolithic 457-line [GameProfile.java](cci:7://file:///Users/mansimanojpatil/Desktop/Pretty/ATSD/MCProtocolLib/protocol/src/main/java/org/geysermc/mcprotocollib/auth/GameProfile.java:0:0-0:0) into their own top-level files to adhere to the Single Responsibility / One Class Per File principle.
2. **Move Method:** Moved the ping/keep-alive validation logic in [ServerListener.java](cci:7://file:///Users/mansimanojpatil/Desktop/Pretty/ATSD/MCProtocolLib/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/ServerListener.java:0:0-0:0) directly into the [KeepAliveState](cci:2://file:///Users/mansimanojpatil/Desktop/Pretty/ATSD/MCProtocolLib/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/ServerListener.java:332:4-336:5) class (`hasTimedOut`, `isPending`, `generateChallenge`). This properly encapsulates the logic that manipulates the [KeepAliveState](cci:2://file:///Users/mansimanojpatil/Desktop/Pretty/ATSD/MCProtocolLib/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/ServerListener.java:332:4-336:5) variables.
3. **Replace Conditional with Polymorphism:** Replaced the 10-line `if-else` chain inside the [ServerboundContainerClickPacket](cci:2://file:///Users/mansimanojpatil/Desktop/Pretty/ATSD/MCProtocolLib/protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/serverbound/inventory/ServerboundContainerClickPacket.java:24:0-123:1) constructor with a clean polymorphic `this.action.actionFrom(param, this.slot)` call. The factory implementation has been shifted directly into the `ContainerActionType` enum constants.
All changes have been successfully verified against `./gradlew build`.
合并状态:未合并 2 条评论