Skip to content

Hotfix CommandAPI throwing errors because of Paper's Brigadier command API #555

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
May 12, 2024

Conversation

DerEchtePilz
Copy link
Member

@DerEchtePilz DerEchtePilz commented May 12, 2024

Some of this is not pretty but doing this the VarHandle-less way also got rid of the exception in the console which I didn't seem to do with VarHandles.

Nevertheless, this should make it possible to at least register commands using Paper 1.20.6 build 65 and onwards.

I plan to handle all this properly in #517

Regards Paper 1.20.6, build 65+, they've merged the Brigadier command API and removed the vanillaCommandDispatcher field.
+ fixed exception appearing in server log, this isn't done with VarHandles but I think because this is a hotfix, it is fine for now.
I will handle all this properly on dev/commandapi-paper and #517
@Sytm
Copy link
Contributor

Sytm commented May 12, 2024

I gave this PR a quick spin with my plugin and it seems to work without any issues

@DerEchtePilz DerEchtePilz merged commit 8a763c9 into dev/dev May 12, 2024
5 checks passed
Comment on lines +97 to +107
private static final Field commandDispatcher;

static {
Field temporary;
try {
temporary = MinecraftServer.class.getDeclaredField("vanillaCommandDispatcher");
} catch (Exception e) {
temporary = null;
}
commandDispatcher = temporary;
}
Copy link
Member

Choose a reason for hiding this comment

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

A field that could be null that doesn't have @Nullable or wrapped in an Optional! 🫢

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants