Tolerate non-numeric segments in Bukkit.getBukkitVersion() (McVersion) - #859
Open
ch4ika wants to merge 2 commits into
Open
Tolerate non-numeric segments in Bukkit.getBukkitVersion() (McVersion)#859ch4ika wants to merge 2 commits into
ch4ika wants to merge 2 commits into
Conversation
…ving McVersion Some server forks append build/commit metadata as extra dot-separated segments (e.g. "26.2.build.17406-6bc38be"), which is not numeric and made the McVersion static initializer throw a NumberFormatException, permanently breaking any feature that touches this class (anvil input included) for the lifetime of the classloader. McVersion now reads only the leading run of numeric major[.minor[.patch]] segments and ignores anything after the first non-numeric one.
providers.exec defaults to the Gradle process's working directory, not the project directory, so nextGitTag() ran 'git describe' against whatever repository the build happened to be invoked from. That only worked by coincidence when this project was built standalone from its own root; included as a composite build from another project it ran git against the wrong repository and failed.
devnatan
approved these changes
Aug 26, 2026
ch4ika
marked this pull request as ready for review
August 26, 2026 07:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Some server forks append build/commit metadata to
Bukkit.getBukkitVersion()as extra dot-separated segments (e.g.26.2.build.17406-6bc38be).McVersion's static initializer assumes every dot-separated segment before the first-is numeric and callsInteger.parseIntdirectly on it, so a segment likebuildthrows aNumberFormatException.Because this happens in a static initializer, the failure is permanent for the classloader's lifetime (
ExceptionInInitializerError, laterNoClassDefFoundError) and takes down every feature that touchesMcVersion— in our case the anvil input feature, breaking any menu that used it to collect text input.Fix
McVersionnow reads only the leading run of numericmajor[.minor[.patch]]segments via a regexlookingAt()match, ignoring anything after the first non-numeric segment, instead of throwing.nextGitTag()in the rootbuild.gradle.ktsrangit describeagainst the Gradle process's working directory rather than the project directory (providers.execdoesn't default toprojectDir), which only worked by coincidence when this project was built standalone. Included as a composite build from another project, it resolved the wrong repository and failed. Fixed by passingworkingDir(project.projectDir)explicitly.Testing
Verified against a full downstream build (Paper plugin consuming this library via a Gradle composite build) —
McVersion.current()no longer throws, and the anvil input feature works again on the affected server fork.