Fix StringIndexOutOfBoundsException on new Minecraft version scheme (26.x) - #59
Open
BinSlayer01 wants to merge 1 commit into
Open
Fix StringIndexOutOfBoundsException on new Minecraft version scheme (26.x)#59BinSlayer01 wants to merge 1 commit into
BinSlayer01 wants to merge 1 commit into
Conversation
Config.loadConfig() parsed the major version with
getBukkitVersion().split(".")[1].substring(0, 2), assuming the legacy
"1.X.Y" format. On the new year-based scheme (e.g. "26.1.2") the second
component is "1", so substring(0, 2) throws StringIndexOutOfBoundsException
and the plugin fails to enable.
Parse defensively: strip the build suffix, then treat a leading "1." as the
legacy scheme (use the minor as the version gate) and any other leading
number as a modern version (>= 1.18 behaviour).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
On Minecraft's new year-based version scheme (e.g.
26.1.2), the plugin fails to enable with:Cause
Config.loadConfig()derives the major version with:This assumes the legacy
1.X.Yformat, wheresplit(".")[1]is the minor ("21","20", …). With the new scheme,getBukkitVersion()is e.g."26.1.2-R0.1-SNAPSHOT", sosplit(".")[1]is"1"— only one character — andsubstring(0, 2)throws.Fix
Parse defensively: strip the build suffix, then treat a leading
1.as the legacy scheme (gate on the minor) and any other leading number as a modern version (≥ 1.18 behaviour).Testing
Built and ran on Spigot 26.1.2: the plugin now enables cleanly, config + messages load, and commands register. Verified the legacy path still behaves the same for
1.xversions.