diff --git a/src/Oxide.Core.csproj b/src/Oxide.Core.csproj index 28c3efcc..c2bd5c69 100644 --- a/src/Oxide.Core.csproj +++ b/src/Oxide.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Plugins/CSPlugin.cs b/src/Plugins/CSPlugin.cs index ee2b02ab..709da639 100644 --- a/src/Plugins/CSPlugin.cs +++ b/src/Plugins/CSPlugin.cs @@ -1,6 +1,7 @@ using Oxide.Core.Libraries; using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; namespace Oxide.Core.Plugins @@ -115,6 +116,16 @@ protected void AddHookMethod(string name, MethodInfo method) hookMethods.Add(new HookMethod(method)); } + internal override bool IsBaseHook(string name) + { + if (string.IsNullOrEmpty(name)) + { + return false; + } + + return Hooks.TryGetValue(name, out List hooks) && hooks.Any(h => h.IsBaseHook); + } + /// /// Calls the specified hook on this plugin /// diff --git a/src/Plugins/Plugin.cs b/src/Plugins/Plugin.cs index 6f6ba6e6..75c54070 100644 --- a/src/Plugins/Plugin.cs +++ b/src/Plugins/Plugin.cs @@ -327,6 +327,8 @@ public object CallHook(string hook, params object[] args) /// protected abstract object OnCallHook(string hook, object[] args); + internal virtual bool IsBaseHook(string name) => false; + /// /// Raises an error on this plugin /// diff --git a/src/Plugins/PluginManager.cs b/src/Plugins/PluginManager.cs index 9bf1f80d..faf40639 100644 --- a/src/Plugins/PluginManager.cs +++ b/src/Plugins/PluginManager.cs @@ -144,7 +144,7 @@ internal void SubscribeToHook(string hook, Plugin plugin) /// internal void UnsubscribeToHook(string hook, Plugin plugin) { - if (!loadedPlugins.ContainsKey(plugin.Name) || !plugin.IsCorePlugin && (hook.StartsWith("IOn") || hook.StartsWith("ICan"))) + if (!loadedPlugins.ContainsKey(plugin.Name) || !plugin.IsCorePlugin && (hook.StartsWith("IOn") || hook.StartsWith("ICan")) || plugin.IsBaseHook(hook)) { return; }