From 35ef6dc824aa4ac3710ea11ff0f8d4a42c9eaa6f Mon Sep 17 00:00:00 2001 From: Yamato Date: Thu, 1 Aug 2024 19:03:34 +0200 Subject: [PATCH 1/3] Fix not returning null --- EXILED/Exiled.API/Features/Player.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 4991e13d4..29ff83b79 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -1266,8 +1266,9 @@ public static Player Get(GameObject gameObject) if (Dictionary.TryGetValue(gameObject, out Player player)) return player; - UnverifiedPlayers.TryGetValue(gameObject, out player); - return player; + if (UnverifiedPlayers.TryGetValue(gameObject, out player)) + return player; + return new(gameObject); } /// From 30f4372bcd806b76a5dd9c29f4be9bbe68bd3e94 Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:46:07 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Jesus QC <69375249+Jesus-QC@users.noreply.github.com> --- EXILED/Exiled.API/Features/Player.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 29ff83b79..8ff95d2fd 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -1268,6 +1268,7 @@ public static Player Get(GameObject gameObject) if (UnverifiedPlayers.TryGetValue(gameObject, out player)) return player; + return new(gameObject); } From 141d97d2829cf450304d57440bb943fc7b286210 Mon Sep 17 00:00:00 2001 From: Yamato Date: Sun, 4 Aug 2024 12:28:20 +0200 Subject: [PATCH 3/3] Little modification --- EXILED/Exiled.API/Features/Player.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 8ff95d2fd..f26cbf6a6 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -1269,7 +1269,10 @@ public static Player Get(GameObject gameObject) if (UnverifiedPlayers.TryGetValue(gameObject, out player)) return player; - return new(gameObject); + if (ReferenceHub.TryGetHub(gameObject, out ReferenceHub hub)) + return new(hub); + + return null; } ///