Beispiel #1
0
        public override Plugin Load(string directory, string name)
        {
            try
            {
                LogDebug($"Load({directory}, {name})");
                if (LoadingPlugins.Contains(name))
                {
                    LogDebug("Return null; (plugin already loading)");
                    return(null);
                }

                var plugin = GetPlugin(name);
                if (plugin == null)
                {
                    LogDebug("Return null; (plugin not found)");
                    return(null);
                }

                LoadingPlugins.Add(plugin.Name);
                Interface.Oxide.NextTick(() => LoadPlugin(plugin));
                LogDebug("Return null; (load on next tick)");
                return(null);
            }
            catch (Exception ex)
            {
                Interface.Oxide.LogException($"Fail to load plugin: {name}", ex);
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads a plugin given the specified name
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public virtual Plugin Load(string directory, string name)
        {
            if (LoadingPlugins.Contains(name))
            {
                Interface.Oxide.LogDebug("Load requested for plugin which is already loading: {0}", name);
                return(null);
            }

            string filename = Path.Combine(directory, name + FileExtension);
            Plugin plugin   = GetPlugin(filename);

            LoadingPlugins.Add(plugin.Name);
            Interface.Oxide.NextTick(() => LoadPlugin(plugin));

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Attempt to asynchronously compile and load plugin
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public override Plugin Load(string directory, string name)
        {
            //if (name == "CSharpCore") return new CSharpCore();

            if (LoadingPlugins.Contains(name))
            {
                Interface.GetMod().LogInfo("Plugin is already being loaded: {0}", name);
                return(null);
            }

            // Let the Oxide core know that this plugin will be loading asynchronously
            LoadingPlugins.Add(name);

            var compilable_plugin = GetCompilablePlugin(extension, directory, name);

            compilable_plugin.Compile(compiled =>
            {
                // Load the plugin assembly if it was successfully compiled
                if (compiled)
                {
                    compilable_plugin.LoadAssembly(plugin =>
                    {
                        LoadingPlugins.Remove(name);
                        if (plugin != null)
                        {
                            LoadedPlugins.Add(plugin);
                        }
                    });
                }
                else
                {
                    LoadingPlugins.Remove(name);
                }
            });

            return(null);
        }
 public void PluginLoadingStarted(CompilablePlugin plugin)
 {
     // Let the Oxide core know that this plugin will be loading asynchronously
     LoadingPlugins.Add(plugin.Name);
     plugin.IsLoading = true;
 }