Skip to content

Conversation

@Wulian233
Copy link
Contributor

由 IDEA 自动完成,涉及文件有点多

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

This PR converts the GameJavaVersion class from a traditional Java class to a record. The change simplifies the code by leveraging Java records' auto-generated constructors, accessors, equals(), and hashCode() methods.

Changes:

  • Converted GameJavaVersion to a record with component and majorVersion fields
  • Updated all usages across the codebase from getter methods (getMajorVersion(), getComponent()) to record accessor methods (majorVersion(), component())
  • Cleaned up imports by expanding wildcard imports to specific imports

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
GameJavaVersion.java Converted class to record, removed manual constructors/getters, added custom equals/hashCode
JavaVersionConstraint.java Updated method calls to use record accessors, reordered imports
MojangJavaRemoteVersion.java Updated to use majorVersion() accessor
MojangJavaDownloadTask.java Updated to use component() and majorVersion() accessors, expanded wildcard import
JavaDownloadDialog.java Updated to use majorVersion() accessor, expanded wildcard import
HMCLJavaRepository.java Updated to use component() accessor, expanded wildcard imports
LauncherHelper.java Updated to use majorVersion() accessor

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

Comment on lines 93 to 101
@Override
public int hashCode() {
return getMajorVersion();
return majorVersion();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GameJavaVersion)) return false;
GameJavaVersion that = (GameJavaVersion) o;
return majorVersion == that.majorVersion;
return this == o || o instanceof GameJavaVersion that && this.majorVersion == that.majorVersion;
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

Custom equals() and hashCode() methods override the record's auto-generated implementations but only use majorVersion, ignoring the component field. This violates the equals/hashCode contract for records and could cause unexpected behavior. If only majorVersion should determine equality, consider removing component from the record or documenting this design decision. Otherwise, remove these custom implementations to use the record's default behavior that considers both fields.

Copilot uses AI. Check for mistakes.
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