Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Disambiguate libraries by their module name. #206

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,14 @@ private String formatError(final ModWithVersionRange modWithVersionRange) {
}

protected String identifyMod(final IModFile modFile) {
if (modFile.getModFileInfo() == null || modFile.getModInfos().isEmpty()) {
if (modFile.getModFileInfo() == null) {
return modFile.getFileName();
}
// If this is a library, it won't have any mod IDs, so we use the module name instead.
if (modFile.getModInfos().isEmpty()) {
LlamaLad7 marked this conversation as resolved.
Show resolved Hide resolved
// Prefix to ensure this cannot collide with any true mod ID.
return "library:" + modFile.getModFileInfo().moduleName();
}

return modFile.getModInfos().stream().map(IModInfo::getModId).collect(Collectors.joining());
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're already fixing up this logic, can we fix this logic here too, by joining them with something that can't be in a mod ID, like + or ,? The current logic would treat a jar containing the mods foo and bar as identical to a jar containing the mod foobar, which it is not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

out of scope IMO

Copy link
Contributor

Choose a reason for hiding this comment

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

The other option is to take just the first mod ID -- which may be more sensible, as that is what becomes the module name. That said -- is there a reason we don't just use the module name in general here? After all, it'll be unique for different mods and for other stuff, but the same between multiple mods that are the "same" mod or whatever.

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ public IConfigurable getConfig() {
return configurable;
}

// These Should never be called as it's only called from ModJarMetadata.version and we bypass that
@Override
public String moduleName() {
return mod.getSecureJar().name();
}

// These Should never be called as it's only called from ModJarMetadata.version and we bypass that
@Override
public String versionString() {
return null;
Expand Down