Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Inconvenient to set values in a Propery Listener/Action #36

Open
My-Name-Is-Jeff opened this issue Feb 3, 2022 · 0 comments
Open

Inconvenient to set values in a Propery Listener/Action #36

My-Name-Is-Jeff opened this issue Feb 3, 2022 · 0 comments

Comments

@My-Name-Is-Jeff
Copy link
Contributor

As seen here (implementation still has the same behavior in the current version of Vigilance), the value of the field is set after the listener is called:

https://github.com/Sk1erLLC/Vigilance/blob/553f6cb8612101ecddaa1fac59b171c1e81a0612/src/main/kotlin/club/sk1er/vigilance/data/PropertyData.kt#L29-L32

This means you cannot directly set any given value in the listener, because it will be overwritten right after the action has been completed

Because of this, to set the same field as the one called in the listener to a different value, you must wait until after the setValue function is completed before calling your own code

Example:

https://github.com/Skytils/SkytilsMod/blob/5aea845da5ecfe8f94a345dab4c15240e2e19096/src/main/kotlin/skytils/skytilsmod/core/Config.kt#L2397

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

No branches or pull requests

1 participant