Skip to content

fix: support Paper 26.x unversioned craftbukkit package#290

Open
charlyg31 wants to merge 5 commits into
HelpChat:mainfrom
charlyg31:fix/paper-26x-craftbukkit-package
Open

fix: support Paper 26.x unversioned craftbukkit package#290
charlyg31 wants to merge 5 commits into
HelpChat:mainfrom
charlyg31:fix/paper-26x-craftbukkit-package

Conversation

@charlyg31

Copy link
Copy Markdown

Paper 26.x removed the version suffix from the craftbukkit package (e.g. org.bukkit.craftbukkit.v1_21_R3 -> org.bukkit.craftbukkit). getCraftClass now tries without suffix first, then falls back to the versioned package for older server versions.

@iGabyTM

iGabyTM commented Jun 7, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, but why does it show that the class content was fully removed then added back?
Also, this may be a micro optimisation but I think you should add an IS_PAPER check first and always look for class with version prefix on spigot.

Pseudo code:

if IS_PAPER
  try 
    get class without versio prefix
  catch exception { }

get class with version prefix

@charlyg31

Copy link
Copy Markdown
Author

Thanks for the feedback!

  1. The full rewrite in the diff was caused by my editing tool - I'll submit a cleaner patch that only modifies the getCraftClass() method.

  2. Agreed, here's the updated pseudo-code I'll implement:

public static Class<?> getCraftClass(@NotNull final String name) throws ClassNotFoundException {
if (IS_PAPER) {
try {
return Class.forName("org.bukkit.craftbukkit." + name);
} catch (ClassNotFoundException ignored) { }
}
return Class.forName("org.bukkit.craftbukkit." + NMS_VERSION + "." + name);
}

I'll push a cleaner commit with this approach.

Paper 26.x removed the version suffix from the craftbukkit package.
Check IS_PAPER first and try without version prefix, then fall back
to the versioned package for older/non-Paper servers.

Fixes HelpChat#196
@charlyg31 charlyg31 force-pushed the fix/paper-26x-craftbukkit-package branch from bf07260 to 698dd4d Compare June 7, 2026 06:37
@charlyg31

Copy link
Copy Markdown
Author

I'm sorry, I'm a beginner in coding and in using GitHub.

@Tanguygab

Copy link
Copy Markdown
Collaborator

Hey, I've double-checked when the change was made, and it turns out Paper changed it back in 1.20.5 while Spigot just did in 26.1.
Could you change the check to CURRENT_VERSION >= 26_1 || IS_PAPER && CURRENT_VERSION >= 1_20_5 ?

@charlyg31

Copy link
Copy Markdown
Author

I think is good now, thanks for your help.

@iGabyTM

iGabyTM commented Jun 7, 2026

Copy link
Copy Markdown
Member

Shouldnt it be 1_26_1 or did they change the versioning to no longer start with 1?

@Tanguygab

Copy link
Copy Markdown
Collaborator

Haven't checked but I'm pretty sure it doesn't start with 1 anymore

@iGabyTM

iGabyTM commented Jun 7, 2026

Copy link
Copy Markdown
Member

And the version checker works fine?
I guess 26.1 turns into 2610 which is higher than let's say 1.12 > 1120.

@charlyg31

Copy link
Copy Markdown
Author

I'm at work now, i check that Tuesday, i dont have computer with Minecraft for try.

@charlyg31

Copy link
Copy Markdown
Author

There's actually a deeper issue here - the version encoding breaks when major > 9.
For Paper 26.1.2, CURRENT_VERSION = 2612 which is less than 12050 (1.20.5),
so the IS_PAPER check would never match on 26.x anyway.

The condition works only because of the first check (>= 2610).
Should getCurrentVersion() be refactored to handle major versions > 9 properly?

@iGabyTM

iGabyTM commented Jun 7, 2026

Copy link
Copy Markdown
Member

This needs to be tested: make the minor and patch numbers two digits.
1.20.1 > 1.20.01 > 12 001
26.1.1 > 26.01.01 > 260 101
26.2 > 26.02.00 > 260 200

The constants will need to be changed to check for 1_20_01 instead of 1_20_1.

@iGabyTM

iGabyTM commented Jun 7, 2026

Copy link
Copy Markdown
Member

The version regex also needs to be updated if we go this way, to capture major, minor and patch individually in order to pad them with 0.

@charlyg31

Copy link
Copy Markdown
Author

You learn me a lot, thanks you so much .

@iGabyTM

iGabyTM commented Jun 7, 2026

Copy link
Copy Markdown
Member

Looks good, but please use a constant for that condition inside getCraftClass and also please define the numbers as major_minor_patch, e.g. 1_20_05, it is easier to read them like this.
Follow the other methods or constants.

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.

3 participants