Skip to content

Add McVersionRemapper for new Paper version format support#340

Merged
twisti-dev merged 2 commits into
version/26.1from
fix/if-mc-version-parser
May 8, 2026
Merged

Add McVersionRemapper for new Paper version format support#340
twisti-dev merged 2 commits into
version/26.1from
fix/if-mc-version-parser

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

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:

  • Added a new McVersionRemapper in McVersionRemapper.kt to patch inventory-framework's version detection logic, ensuring correct parsing of Paper's new version format by replacing the internal countColons method.
  • Updated InventoryLoader to invoke McVersionRemapper.remap() during initialization, applying the patch automatically when necessary.

Release versioning:

  • Bumped project version from 3.9.3 to 3.9.4 in gradle.properties to reflect the compatibility fix.

twisti-dev added 2 commits May 9, 2026 00:40
… format

- implement McVersionRemapper to handle Paper's new version format with additional dots
- update InventoryLoader to call remap method during initialization
@twisti-dev twisti-dev self-assigned this May 8, 2026
Copilot AI review requested due to automatic review settings May 8, 2026 22:44
@twisti-dev twisti-dev merged commit c4ee9d0 into version/26.1 May 8, 2026
4 of 8 checks passed
@twisti-dev twisti-dev deleted the fix/if-mc-version-parser branch May 8, 2026 22:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 McVersionRemapper that rewrites inventory-framework’s private McVersion.countColons(String): Int behavior to detect numeric patch versions under the new Paper format.
  • Updated InventoryLoader to run the new remapper during initialization (alongside existing inventory-framework remappers).
  • Bumped project version from 3.9.3 to 3.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)
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