Skip to content

(A)sync handling of Menu requirements - #308

Open
petulikan1 wants to merge 1 commit into
HelpChat:mainfrom
petulikan1:main
Open

petulikan1 wants to merge 1 commit into
HelpChat:mainfrom
petulikan1:main

Conversation

@petulikan1

Copy link
Copy Markdown

Greetings, I'd like to propose of adding this feature - being able to parse menu open requirements in sync.

This feature would allow server owners to change, whether their menu open requirements should be parsed async (default behavior) or with a config option (for each menu) parse_requirements_async set to false - sync.

The reason for this feature is simple - some menus are built around requirements, and one of these requirements can be (like in our case) a string equals check, where, when before it's evaluated, it goes trough a PlaceholderAPI parse method, to set all the necessary placeholders. In our case, this sets the result of a CheckItem Expansion placeholder, sadly, due to how this expansion works - it doesn't disambiguate whether the code from which it was run from is sync or async. To mitigate these race conditions, we have made our own fork of this expansion and fixed this behavior to strictly force any item interaction on the main thread, to prevent race conditions (as we were experiencing before). Sadly, that created another problem - menus. Due to how our menus work, where we have quite a lot of placeholders, to handle all possible scenarios of all kinds of items, that creates a delay where every single placeholder parse has to be run on the main thread.

That's why I'm proposing of adding this as an optional feature - when server administrators deem necessary for their requirement logic to be run on the main thread, they can simply do so by adding a config option and setting it to false.

Here are examples of running the requirements check in async and sync.

ASYNC
https://youtu.be/wfCdNEcx9hw

SYNC
https://youtu.be/rEXl_sv2zm0

Thank you for reading and for considering this pull request.

(Disclaimer - NO AI was used in writing of the changes, writing of this pull request message, making of the videos -- Everything was done by me - human - petulikan1)
(All my commits are signed by my GPG key)

@TheCashFire

Copy link
Copy Markdown

I can second these changes being useful. I can open my menus with 3,000+ placeholders in under a second now, where before it would take 6-8 seconds. There is no notable TPS drop I can see.

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