Skip to content

Conversation

@yushijinhun
Copy link
Member

Authlib-injector is already bundled into HMCL in #4246. Due to this, AuthlibInjectorDownloader is no longer needed. This commit removes AuthlibInjectorDownloader, AuthlibInjectorDownloadException, AuthlibInjectorExtractor, AuthlibInjectorArtifactInfo, and AuthlibInjectorArtifactProvider classes, plus the account.failed.injector_download_failure i18n key. AuthlibInjectorArtifactProvider is replaced with Supplier<Path> to provide the jar path of authlib-injector.

Authlib-injector is already bundled into HMCL in HMCL-dev#4246.
Due to this, `AuthlibInjectorDownloader` is no longer needed.
This commit removes `AuthlibInjectorDownloader`, `AuthlibInjectorDownloadException`,
`AuthlibInjectorExtractor`, `AuthlibInjectorArtifactInfo`, and `AuthlibInjectorArtifactProvider` classes,
plus the `account.failed.injector_download_failure` i18n key.
`AuthlibInjectorArtifactProvider` is replaced with `Supplier<Path>` to provide
the jar path of authlib-injector.
…tor-download

# Conflicts:
#	HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java
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 removes the authlib-injector download infrastructure since authlib-injector is now bundled directly with HMCL (as mentioned in #4246). The change simplifies the codebase by replacing the complex download/extraction provider system with a straightforward Supplier<Path> approach.

Key Changes:

  • Replaced AuthlibInjectorArtifactProvider interface with Supplier<Path> for providing authlib-injector JAR paths
  • Removed asynchronous download logic from AuthlibInjectorAccount, simplifying the login flow to be synchronous
  • Implemented new extraction logic in Accounts.resolveAuthlibInjectorArtifact() to extract bundled authlib-injector on first use

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
OfflineAccountFactory.java Updated constructor and method calls to use Supplier<Path> instead of AuthlibInjectorArtifactProvider
OfflineAccount.java Simplified artifact handling by removing async operations and directly using the Path supplier
BoundAuthlibInjectorAccountFactory.java Changed parameter type from AuthlibInjectorArtifactProvider to Supplier<Path>
AuthlibInjectorAccountFactory.java Updated to use Supplier<Path> for artifact provision
AuthlibInjectorAccount.java Removed async download logic, simplified to synchronous artifact resolution
SimpleAuthlibInjectorArtifactProvider.java Deleted - no longer needed with bundled artifact approach
AuthlibInjectorExtractor.java Deleted - extraction logic moved inline to Accounts class
AuthlibInjectorDownloader.java Deleted - download functionality removed as artifact is bundled
AuthlibInjectorDownloadException.java Deleted - exception no longer needed
AuthlibInjectorArtifactProvider.java Deleted - interface replaced by Supplier<Path>
AuthlibInjectorArtifactInfo.java Deleted - artifact metadata no longer needed
Accounts.java Added resolveAuthlibInjectorArtifact() method to handle bundled artifact extraction on demand
LauncherHelper.java Removed exception handling for AuthlibInjectorDownloadException
I18N*.properties Removed account.failed.injector_download_failure key from all language files
Comments suppressed due to low confidence (1)

HMCLCore/src/main/java/org/jackhuang/hmcl/auth/offline/OfflineAccount.java:108

  • The call to authlibInjectorArtifactProvider.get() can throw UncheckedIOException (from the extraction logic in Accounts.resolveAuthlibInjectorArtifact), but this unchecked exception is not handled. Consider wrapping the call in a try-catch block and converting it to an AuthenticationException to maintain consistent error handling behavior.
    public AuthInfo logIn() throws AuthenticationException {

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

if (artifact.isPresent() && prefetchedMeta.isPresent()) {
return new AuthlibInjectorAuthInfo(auth, artifact.get(), server, prefetchedMeta.get());
if (prefetchedMeta.isPresent()) {
Path artifactPath = artifactProvider.get();
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

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

The call to artifactProvider.get() can throw UncheckedIOException (from the extraction logic in Accounts.resolveAuthlibInjectorArtifact), but this unchecked exception is not handled. Consider wrapping the call in a try-catch block and converting it to an AuthenticationException to maintain consistent error handling behavior.

Copilot uses AI. Check for mistakes.
} catch (Exception e) {
throw new AuthenticationException(e);
}
return new OfflineAuthInfo(authInfo, authlibInjectorArtifactProvider.get());
Copy link
Member

@Glavo Glavo Dec 19, 2025

Choose a reason for hiding this comment

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

这里是可以抛出 UncheckedIOException 的,这处修改让语义变化了。

@Glavo
Copy link
Member

Glavo commented Dec 19, 2025

要不把 Supplier<Path> 改成 ExceptionalSupplier<Path, IOException>,或者把 AuthlibInjectorArtifactProvider 弄回来吧,把相关的下载报错改成解压报错就行。

@yushijinhun
Copy link
Member Author

要不把 Supplier<Path> 改成 ExceptionalSupplier<Path, IOException>,或者把 AuthlibInjectorArtifactProvider 弄回来吧,把相关的下载报错改成解压报错就行。

解压报错应该非常罕见吧?从 JAR 内读取资源很难想象会出错,出错也是写入到磁盘上时候出错。

@Glavo
Copy link
Member

Glavo commented Dec 20, 2025

从 JAR 内读取资源很难想象会出错,出错也是写入到磁盘上时候出错。

对,就是写入硬盘时可能会产生 IOException,这个可能性我觉得不能忽略。

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