Skip to content

[CHANGE] Sort GameVersions set#4

Open
MattSturgeon wants to merge 3 commits into
firstdarkdev:mainfrom
MattSturgeon:sort-versions
Open

[CHANGE] Sort GameVersions set#4
MattSturgeon wants to merge 3 commits into
firstdarkdev:mainfrom
MattSturgeon:sort-versions

Conversation

@MattSturgeon

Copy link
Copy Markdown
Contributor

As per my aside in #3, a sorted list of valid versions is easier to digest.

If I understand TObjectLongHashMap, the map is implemented as an array so insertion order is preserved. Therefore, I opted to sort before inserting. Alternatively, we could sort only when rendering the exception message.

@hypherionmc

Copy link
Copy Markdown
Member

Are you happy with this PR, or do you still have anything else you want to add?

@MattSturgeon

Copy link
Copy Markdown
Contributor Author

If I understand TObjectLongHashMap, the map is implemented as an array so insertion order is preserved. Therefore, I opted to sort before inserting.

I tested this by adding an invalid version to src/test/java/CurseUploadTest.java and I was incorrect. The logged error is still in a random order.

Alternatively, we could sort only when rendering the exception message.

I'll do this instead.

@MattSturgeon MattSturgeon marked this pull request as draft July 1, 2026 13:22
@MattSturgeon

MattSturgeon commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Alternatively, we could sort only when rendering the exception message.

I'll do this instead.

Done and tested:

java.lang.IllegalArgumentException: 26.3-snapshot is not a valid game version. Valid versions are: 1.0, 1.0.0, 1.1, 1.10, 1.10-snapshot, 1.10.1, 1.10.2, 1.11, 1.11-snapshot, 1.11.1, 1.11.2, 1.12, 1.12-snapshot, 1.12.1, 1.12.2, 1.13, 1.13-snapshot, 1.13.1, 1.13.2, 1.14, 1.14-snapshot, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.15, 1.15-snapshot, 1.15.1, 1.15.2, 1.16, 1.16-snapshot, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.17, 1.17-snapshot, 1.17.1, 1.18, 1.18-snapshot, 1.18.1, 1.18.2, 1.19, 1.19-snapshot, 1.19.1, 1.19.2, 1.19.3, 1.19.3-snapshot, 1.19.4, 1.19.4-snapshot, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.20, 1.20-snapshot, 1.20.1, 1.20.2, 1.20.2-snapshot, 1.20.3, 1.20.3-snapshot, 1.20.4, 1.20.5, 1.20.5-snapshot, 1.20.6, 1.21, 1.21-snapshot, 1.21.1, 1.21.1-snapshot, 1.21.10, 1.21.11, 1.21.11-snapshot, 1.21.2, 1.21.2-snapshot, 1.21.3, 1.21.4, 1.21.4-snapshot, 1.21.5, 1.21.5-snapshot, 1.21.6, 1.21.6-snapshot, 1.21.7, 1.21.8, 1.21.9, 1.21.9-snapshot, 1.3.1, 1.3.2, 1.4.2, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.6.1, 1.6.2, 1.6.4, 1.7.10, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.8, 1.8-snapshot, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.8.8, 1.8.9, 1.9, 1.9-snapshot, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 26.1, 26.1-snapshot, 26.1.1, 26.1.2, 26.2, beta 1.6.6, beta 1.7, beta 1.7.3, beta 1.8.1, client, fabric, flint loader, forge, java 10, java 11, java 12, java 13, java 14, java 15, java 16, java 17, java 18, java 19, java 20, java 21, java 22, java 25, java 6, java 7, java 8, java 9, neoforge, quilt, rift, risugami's modloader, server

Are you happy with this PR, or do you still have anything else you want to add?

Happy now it's tested (and fixed)


I kept a for -> stream refactor in a separate commit, which is equivalent to the old behaviour but a bit easier to read as a "data pipeline". If you prefer the old style, let me know and I'll drop that commit.

@MattSturgeon MattSturgeon marked this pull request as ready for review July 1, 2026 13:36
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