Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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
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! 🫢

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