Skip to content

Fix async. PlayerStatisticIncrementEvent error by forcing event to run sync. - #2117

Open
Qumoo wants to merge 2 commits into
IzzelAliz:FeudalKingsfrom
Qumoo:FeudalKings
Open

Fix async. PlayerStatisticIncrementEvent error by forcing event to run sync.#2117
Qumoo wants to merge 2 commits into
IzzelAliz:FeudalKingsfrom
Qumoo:FeudalKings

Conversation

@Qumoo

@Qumoo Qumoo commented Apr 16, 2026

Copy link
Copy Markdown

We are using Pixelmon Reforged on one of our servers and when a player joins it results in this error.
My cautious guess would be that NeoForge allows the stat increment to be run async whereas Bukkit does not.

This patch is aimed on forcing the event to be run sync. on the Bukkit side.
message.txt

@InitAuther97

InitAuther97 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

This simply won't work as you are expecting.
Inject works by creating an instance of CallbackInfo and pass it into the injector. When the injector returns, the method will check if callback info is cancelled. If it's not it will proceed.
In this case, callback info is submitted to the main thread and wait for processing and cancellation. Meanwhile the injector has already returned and the method checks CallbackInfo and discover it's not cancelled, so the statistics increment will proceed.
You can notice that the cancellation of the event does not work anymore. A good fix might be a main thread check before firing the event. If it's not on the server thread, submit it to the server thread but do not process cancellation. If it's on the server thread, fire synchronously and process cancellation if needed. Doing like this makes the event cancellation useless even on the server thread, which breaks all plugins using this event.

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