diff --git a/Exiled.API/Features/Core/Generic/EBehaviour.cs b/Exiled.API/Features/Core/Generic/EBehaviour.cs index 913d05f62c..ad8a885413 100644 --- a/Exiled.API/Features/Core/Generic/EBehaviour.cs +++ b/Exiled.API/Features/Core/Generic/EBehaviour.cs @@ -63,14 +63,13 @@ protected virtual void FindOwner() // Or create an specific Interaface requesting to implement this method MethodInfo method = typeof(T).GetMethod("Get", BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(GameObject) }, null); - if (method != null) - { - Owner = (T)method.Invoke(null, new object[] { Base }); - } - else - { + if (method == null) throw new MissingMethodException($"Method 'Get(GameObject)' not found in class '{typeof(T).Name}'."); - } + + if (typeof(T).IsAssignableFrom(method.ReturnType)) + throw new MissingMethodException($"Method 'Get(GameObject)' in class '{typeof(T).Name}' do not return an instance of {typeof(T).Name} but {method.ReturnType}."); + + Owner = (T)method.Invoke(null, new object[] { Base }); } ///