Skip to content

Add hangar command to download plugins from Hangar - #947

Merged
itzg merged 1 commit into
itzg:mainfrom
caunt:hangar
Nov 15, 2026
Merged

itzg merged 1 commit into
itzg:mainfrom
caunt:hangar

Conversation

@caunt

@caunt caunt commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

For itzg/docker-minecraft-server#2103
Draft PR itzg/docker-minecraft-server#4392

Adds a hangar command, modeled after modrinth as suggested in that issue, that downloads plugins from Hangar.

  • --projects takes slugs or IDs with an optional :version, @ listing files and a ? suffix for optional projects, like modrinth
  • Without a version, the newest version of --channel (default Release, Hangar's default channel) that supports --platform (default PAPER) and --game-version is selected
  • Hosted files are verified against their SHA-256, so an existing file whose name is reused by a newer build gets replaced. External downloads, such as Floodgate's, are refreshed when the remote file is modified
  • Removed projects are cleaned up through the manifest
  • Projects are resolved one at a time to stay within Hangar's limit of 20 requests per 5 seconds

Testing

  • HangarCommandTest with WireMock (./gradlew check and checkReadme pass)
  • Tested against Hangar API with ViaVersion,Maintenance:4.3.0,Floodgate and an optional missing project, then again with Floodgate removed: downloads, skipping on re-run, the optional skip and cleanup - all worked

Adds a `hangar` command that downloads plugins from Hangar, PaperMC's
plugin repository, for the requested platform and Minecraft version.

- Projects are given as slug or ID with an optional version name,
  `@` listing files, and a `?` suffix for optional projects
- When no version is given, the newest version of `--channel`
  (default Release) supporting the platform and game version is used
- Hangar hosted files are verified against their SHA-256 and replaced
  when an existing file with the same name has different content
- External downloads are refreshed when the remote file was modified
- Previously downloaded files of removed projects are cleaned up
  via the manifest

@itzg itzg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for adding this. I'll have the merge trigger a minor version bump. You can update the version in the Dockerfile of your draft PR. Or I can let Renovate apply the upgrade first.

throw e;
}

return Stream.of(download(sharedFetch, download));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

A stream-of-one seems unnecessary here. It's a stream in others like modrinth since a single project reference could result in transitive dependencies getting pulled also.

For future proofing, I'm good with leaving this as is.

Comment on lines +150 to +160
download = resolveDownload(hangarApiClient, projectRef)
.block();
} catch (InvalidParameterException e) {
if (projectRef.isOptional()) {
log.warn("Optional project '{}' is not available β€” skipping: {}", projectRef.getSlugOrId(), e.getMessage());
return Stream.empty();
}
throw e;
}

return Stream.of(download(sharedFetch, download));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

It would have been ideal to keep the reactive chain between the metadata resolution and the file download; however, I can appreciate that retries within a reactive chain get ugly.

@itzg itzg added the release/minor On merge, creates a new release with a minor version bump. label Nov 15, 2026
@itzg
itzg merged commit c55153e into itzg:main Nov 15, 2026
1 check passed
@itzg

itzg commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Could also add support to the mc-proxy image after this itzg/docker-mc-proxy#427

@itzg

itzg commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Image updated with itzg/docker-minecraft-server#4395

@caunt

caunt commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the merge! 🀝❀️
I'll do it in mc-proxy next.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request release/minor On merge, creates a new release with a minor version bump.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants