You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think most plugin devs use the UnturnedPlayer class because it provides multiple shortcuts that are very handy.
But most of the factory methods dont work as expected and can result in many issues.
This has been a issue in RocketMod too for a long long time. UnturnedPlayer.FromName only returns a valid UnturnedPlayer object if an actual player is found (how it should work).
But UnturnedPlayer.FromCSteamID will always return a valid UnturnedPlayer object if the CSteamID isnt null or empty or 0.
That means that you will get a object back even if no actual player exists.
When you use that object it will throw error out like nothing because it's player object is null. https://github.com/SmartlyDressedGames/Legally-Distinct-Missile/blob/master/Rocket.Unturned/Player/UnturnedPlayer.cs#L170
So most of the time you have to check if your UnturnedPlayer object is null and if the UnturnedPlayer.Player object is null.
I think that UnturnedPlayer.FromCSteamID should only return a valid UnturnedPlayer object if an actual player is found.
The text was updated successfully, but these errors were encountered:
On the one hand I am hesitant to change the behavior of existing Rocket code, but I have seen a lot of exceptions related to the unusual way those method work. Your proposal seems reasonable to me, and returning null in those cases is how I would expect them to work.
Would anyone else like to weigh in on this or voice their thoughts?
I think most plugin devs use the UnturnedPlayer class because it provides multiple shortcuts that are very handy.
But most of the factory methods dont work as expected and can result in many issues.
This has been a issue in RocketMod too for a long long time.
UnturnedPlayer.FromName only returns a valid UnturnedPlayer object if an actual player is found (how it should work).
But UnturnedPlayer.FromCSteamID will always return a valid UnturnedPlayer object if the CSteamID isnt null or empty or 0.
That means that you will get a object back even if no actual player exists.
When you use that object it will throw error out like nothing because it's player object is null.
https://github.com/SmartlyDressedGames/Legally-Distinct-Missile/blob/master/Rocket.Unturned/Player/UnturnedPlayer.cs#L170
So most of the time you have to check if your UnturnedPlayer object is null and if the UnturnedPlayer.Player object is null.
I think that UnturnedPlayer.FromCSteamID should only return a valid UnturnedPlayer object if an actual player is found.
The text was updated successfully, but these errors were encountered: