Example #1
0
 public void LoadPlugins()
 {
     if (CoreConfig.GetInstance().GetBoolValue("python", "enabled"))
     {
         foreach (string name in GetPluginNames())
         {
             LoadPlugin(name);
         }
     }
     else
     {
         Logger.LogDebug("[PYPluginLoader] Python plugins are disabled in Core.cfg.");
     }
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pluton.PYPlugin"/> class.
        /// </summary>
        /// <param name="name">Name.</param>
        /// <param name="code">Code.</param>
        /// <param name="rootdir">Rootdir.</param>
        public PYPlugin(string name, string code, DirectoryInfo rootdir) : base(name, rootdir)
        {
            Type = PluginType.Python;

            if (CoreConfig.GetInstance().GetBoolValue("python", "checkHash") && !code.VerifyMD5Hash())
            {
                Logger.LogDebug(String.Format("[Plugin] MD5Hash not found for: {0} [{1}]!", name, Type));
                State = PluginState.HashNotFound;
                return;
            }

            System.Threading.ThreadPool.QueueUserWorkItem(
                new System.Threading.WaitCallback(a => Load(code)), null);
        }
Example #3
0
        public static void AttachBootstrap()
        {
            try {
                DirectoryConfig.GetInstance();
                CoreConfig.GetInstance();
                Config.GetInstance();

                if (!pluton.enabled)
                {
                    Debug.Log("[Bootstrap] Pluton is disabled!");
                    return;
                }

                Init();

                PlutonLoaded = true;
                Console.WriteLine("Pluton Loaded!");
            } catch (Exception ex) {
                Debug.LogException(ex);
                Debug.Log("[Bootstarp] Error while loading Pluton!");
            }
        }
Example #4
0
        public static void AttachBootstrap()
        {
            try {
                Hooks.CreateOrUpdateSubjects();

                System.Reflection.Assembly executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
                Type[] types = executingAssembly.GetTypes();
                for (int i = 0; i < types.Length; i++)
                {
                    object[] customAttributes = types[i].GetCustomAttributes(typeof(ConsoleSystem.Factory), false);
                    if (customAttributes != null && customAttributes.Length != 0)
                    {
                        ConsoleSystem.Factory factory = customAttributes[0] as ConsoleSystem.Factory;
                        typeof(ConsoleSystem.Index).CallStaticMethod("BuildFields", types[i], factory);
                        typeof(ConsoleSystem.Index).CallStaticMethod("BuildProperties", types[i], factory);
                        typeof(ConsoleSystem.Index).CallStaticMethod("BuildFunctions", types[i], factory);
                    }
                }

                DirectoryConfig.GetInstance();
                CoreConfig.GetInstance();
                Config.GetInstance();

                if (!pluton.enabled)
                {
                    Debug.Log("[Bootstrap] Pluton is disabled!");
                    return;
                }

                Init();

                PlutonLoaded = true;
                Console.WriteLine("Pluton Loaded!");
            } catch (Exception ex) {
                Debug.LogException(ex);
                Debug.Log("[Bootstarp] Error while loading Pluton!");
            }
        }
Example #5
0
        public static void reload(ConsoleSystem.Arg arg)
        {
            if (PluginLoader.GetInstance().Plugins.ContainsKey(arg.ArgsStr))
            {
                PluginLoader.GetInstance().ReloadPlugin(arg.ArgsStr);
                arg.ReplyWith(String.Format("{0} plugin reloaded!", arg.ArgsStr));
            }
            else if (arg.ArgsStr == "")
            {
                DirectoryConfig.GetInstance().Reload();
                CoreConfig.GetInstance().Reload();
                Config.GetInstance().Reload();

                Server.GetInstance().LoadLoadouts();

                if (Server.GetInstance().Loaded)
                {
                    Hooks.On_ServerInit();
                }

                PluginLoader.GetInstance().ReloadPlugins();

                arg.ReplyWith("Pluton reloaded!");

                var planes = (from plane in UnityEngine.Object.FindObjectsOfType <CargoPlane>()
                              where plane.transform.position.x == 0f && plane.transform.position.z == 0f
                              select plane).ToList();
                planes.ForEach(p => p.SendMessage("KillMessage", UnityEngine.SendMessageOptions.DontRequireReceiver));
                if (planes.Count != 0)
                {
                    Pluton.Logger.LogWarning(String.Format("Destroyed {0} plane at Vector3.zero", planes.Count));
                }
            }
            else
            {
                arg.ReplyWith(String.Format("Couldn't find plugin: {0}!", arg.ArgsStr));
            }
        }
Example #6
0
        public override void Load(string code = "")
        {
            try {
                byte[] bin = File.ReadAllBytes(code);
                if (CoreConfig.GetInstance().GetBoolValue("csharp", "checkHash") && !bin.VerifyMD5Hash())
                {
                    Logger.LogDebug(String.Format("[Plugin] MD5Hash not found for: {0} [{1}]!", Name, Type));
                    State = PluginState.HashNotFound;
                    return;
                }

                LoadReferences();

                Assembly assembly  = Assembly.Load(bin);
                Type     classType = assembly.GetType(Name + "." + Name);
                if (classType == null || !classType.IsSubclassOf(typeof(CSharpPlugin)) || !classType.IsPublic || classType.IsAbstract)
                {
                    throw new TypeLoadException("Main module class not found:" + Name);
                }

                Engine = (CSharpPlugin)Activator.CreateInstance(classType);

                Engine.Plugin   = this;
                Engine.Commands = chatCommands;
                Engine.ServerConsoleCommands = consoleCommands;

                Globals = (from method in classType.GetMethods()
                           select method.Name).ToList <string>();

                State = PluginState.Loaded;
            } catch (Exception ex) {
                Logger.LogException(ex);
                State = PluginState.FailedToLoad;
            }

            PluginLoader.GetInstance().OnPluginLoaded(this);
        }
Example #7
0
 public bool CheckDependencies()
 {
     return(CoreConfig.GetInstance().GetBoolValue("javascript", "enabled") &&
            File.Exists(Path.Combine(Path.Combine(Util.GetServerFolder(), "Managed"), "Jint.dll")));
 }
Example #8
0
 public bool CheckDependencies()
 {
     return(CoreConfig.GetInstance().GetBoolValue("python", "enabled") &&
            File.Exists(Path.Combine(Path.Combine(Util.GetServerFolder(), "Managed"), "IronPython.Deps.dll")));
 }
Example #9
0
 public bool CheckDependencies()
 {
     return(CoreConfig.GetInstance().GetBoolValue("lua", "enabled") &&
            File.Exists(Path.Combine(Path.Combine(Util.GetServerFolder(), "Managed"), "MoonSharp.Interpreter.dll")));
 }
Example #10
0
 public bool CheckDependencies()
 {
     return(CoreConfig.GetInstance().GetBoolValue("php", "enabled") &&
            File.Exists(Path.Combine(Path.Combine(Util.GetServerFolder(), "Managed"), "PhpNetCore.dll")) &&
            File.Exists(Path.Combine(Path.Combine(Util.GetServerFolder(), "Managed"), "PhpNetClassLibrary.dll")));
 }
 public bool CheckDependencies()
 {
     return(CoreConfig.GetInstance().GetBoolValue("csharp", "enabled"));
 }