Add McVersionRemapper for new Paper version format support#340
Merged
Conversation
… format - implement McVersionRemapper to handle Paper's new version format with additional dots - update InventoryLoader to call remap method during initialization
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a ByteBuddy-based remapper to patch inventory-framework’s internal Minecraft version parsing so it can correctly interpret Paper’s newer version string formats (e.g. 26.1.2.build.23-alpha) and applies the patch during inventory framework initialization.
Changes:
- Added
McVersionRemapperthat rewrites inventory-framework’s privateMcVersion.countColons(String): Intbehavior to detect numeric patch versions under the new Paper format. - Updated
InventoryLoaderto run the new remapper during initialization (alongside existing inventory-framework remappers). - Bumped project version from
3.9.3to3.9.4.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/inventory/framework/McVersionRemapper.kt | Adds ByteBuddy ASM visitor to override inventory-framework’s version “dot counting” logic for new Paper version formats. |
| surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/inventory/framework/InventoryLoader.kt | Ensures the new remapper is applied at inventory framework load time. |
| gradle.properties | Version bump to publish the compatibility fix. |
| fun isRemapNecessary(): Boolean { | ||
| return try { | ||
| val version = Bukkit.getBukkitVersion() | ||
| version.contains(".build.") || hasNumericPatchVersionPart(version) |
Comment on lines
+55
to
+63
| val locator = ClassFileLocator.ForClassLoader.of(javaClass.classLoader) | ||
| val typePool = TypePool.Default.of(locator) | ||
| val typeDescription = typePool.describe(MC_VERSION_INTERNAL.replace("/", ".")).resolve() | ||
|
|
||
| ByteBuddy() | ||
| .redefine<Any>(typeDescription, locator) | ||
| .visit(McVersionClassVisitorWrapper()) | ||
| .make() | ||
| .load(javaClass.classLoader, ClassLoadingStrategy.Default.INJECTION) |
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.
This pull request addresses compatibility issues with Paper's new Minecraft version format by introducing a remapper for the inventory-framework library. The main goal is to ensure correct version parsing in environments using the new version scheme (e.g.,
26.1.2.build.23-alpha), which previously caused inventory-framework to misinterpret the Minecraft version.Version compatibility improvements:
McVersionRemapperinMcVersionRemapper.ktto patch inventory-framework's version detection logic, ensuring correct parsing of Paper's new version format by replacing the internalcountColonsmethod.InventoryLoaderto invokeMcVersionRemapper.remap()during initialization, applying the patch automatically when necessary.Release versioning:
3.9.3to3.9.4ingradle.propertiesto reflect the compatibility fix.