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

Occasional NullReferenceException in UnturnedPlayerEvents.InternalOnExperienceChanged #43

Open
aviadmini opened this issue Jul 20, 2021 · 4 comments

Comments

@aviadmini
Copy link

Here:
https://github.com/SmartlyDressedGames/Legally-Distinct-Missile/blob/master/Rocket.Unturned/Events/UnturnedPlayerEvents.cs#L206-L212

In some cases when a player connects and an OpenMod plugin modifies player experience UnturnedPlayerEvents.InternalOnExperienceChanged throws NRE. I suspect it's because an instance of UnturnedPlayerEvents component hasn't been attached to the player yet.

This could be fixed by adding a null check in the method but that's not a good solution because it would cause inconsistency in events.

@SDGNelson
Copy link
Member

What do you propose?

@aviadmini
Copy link
Author

Adding a null check and a warning about event not being processed by rocket component. It's debatably better than exceptions.

I currently do not know of a good solution. Somehow we'd need to ensure that rocket component UnturnedPlayerEvents gets attached before OpenMod events are fired.
Maybe this is possible to do by reordering delegates in Provider.onServerConnected += OnPlayerConnected; ?

@SDGNelson
Copy link
Member

Sorry for my delay. Maybe it should just silently check for null.

@aviadmini
Copy link
Author

aviadmini commented Jul 27, 2021

That doesn't solve the inconsistency issue. Ideally we want both openmod and rocketmod to assign their delegates before this event fires. So that neither of them misses it

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

2 participants