Beispiel #1
0
        public static bool ConsoleReceived(ref ConsoleSystem.Arg a)
        {
            if (((a.argUser == null) && (a.Class == "magmaweb")) && (a.Function == "handshake"))
            {
                a.ReplyWith("All Good !");
                return(true);
            }
            bool external = a.argUser == null;

            if (OnConsoleReceived != null)
            {
                OnConsoleReceived(ref a, external);
            }
            if ((a.Class == "magma") && (a.Function.ToLower() == "reload"))
            {
                if ((a.argUser != null) && a.argUser.admin)
                {
                    PluginEngine.GetPluginEngine().ReloadPlugins(Magma.Player.FindByPlayerClient(a.argUser.playerClient));
                    a.ReplyWith("Magma: Reloaded");
                }
                else if (external)
                {
                    PluginEngine.GetPluginEngine().ReloadPlugins(null);
                    a.ReplyWith("Magma: Reloaded");
                }
            }
            if ((a.Reply != null) && (a.Reply != ""))
            {
                a.ReplyWith("Magma: " + a.Class + "." + a.Function + " was executed!");
                return(true);
            }
            return(false);
        }
 private void Invoke(string name, params object[] obj)
 {
     try
     {
         PluginEngine.GetPluginEngine().Interpreter.Run(this.Code);
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Server", Server.GetServer());
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Data", Data.GetData());
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("DataStore", DataStore.GetInstance());
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Util", Util.GetUtil());
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Web", new Web());
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Time", this);
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("World", World.GetWorld());
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Plugin", this);
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("MySQL", typeof(MySQL));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("MySQLRow", typeof(MySQL.Row));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("MySQLField", typeof(MySQL.Field));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("MySQLResult", typeof(MySQL.Result));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("MySQLRecord", typeof(MySQL.Record));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Helper", typeof(Helper));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("IniFile", typeof(IniFile));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("UserFlags", typeof(UserFlags));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("UserData", typeof(UserData));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("UserBanned", typeof(UserBanned));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Countdown", typeof(Countdown));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Banned", typeof(Banned));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Users", typeof(Users));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Blocklist", typeof(Blocklist));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("UserEconomy", typeof(UserEconomy));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Economy", typeof(Economy));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("ClanData", typeof(ClanData));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("ClanLevel", typeof(ClanLevel));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("ClanMemberFlags", typeof(ClanMemberFlags));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Clans", typeof(Clans));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("ClanFlags", typeof(ClanFlags));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("WorldZone", typeof(WorldZone));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("ZoneFlags", typeof(ZoneFlags));
         PluginEngine.GetPluginEngine().Interpreter.SetParameter("Zones", typeof(Zones));
         if (obj != null)
         {
             PluginEngine.GetPluginEngine().Interpreter.CallFunction(name, obj);
         }
         else
         {
             PluginEngine.GetPluginEngine().Interpreter.CallFunction(name, new object[0]);
         }
     }
     catch (Exception ex)
     {
         Console.Write(string.Concat(new string[]
         {
             "Error invoking function : ",
             name,
             "\nFrom : ",
             this.path,
             "\n\n",
             ex.ToString()
         }));
     }
 }
 public static PluginEngine GetPluginEngine()
 {
     if (PluginEngine.PE == null)
     {
         PluginEngine.PE = new PluginEngine();
         PluginEngine.PE.Init();
     }
     return(PluginEngine.PE);
 }
        public static bool ConsoleReceived(ref ConsoleSystem.Arg a)
        {
            bool result;

            if (a.argUser == null && a.Class == "magmaweb" && a.Function == "handshake")
            {
                a.ReplyWith("All Good !");
                result = true;
            }
            else
            {
                bool flag = a.argUser == null;
                if (Hooks.OnConsoleReceived != null)
                {
                    Hooks.OnConsoleReceived(ref a, flag);
                }
                if (a.Class == "magma" && a.Function.ToLower() == "reload")
                {
                    if (a.argUser != null && a.argUser.admin)
                    {
                        PluginEngine.GetPluginEngine().ReloadPlugins(Player.FindByPlayerClient(a.argUser.playerClient));
                        a.ReplyWith("Magma: Reloaded");
                    }
                    else if (flag)
                    {
                        PluginEngine.GetPluginEngine().ReloadPlugins(null);
                        a.ReplyWith("Magma: Reloaded");
                    }
                }
                if (a.Reply != null && a.Reply != "")
                {
                    a.ReplyWith(string.Concat(new string[]
                    {
                        "Magma: ",
                        a.Class,
                        ".",
                        a.Function,
                        " was executed!"
                    }));
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
Beispiel #5
0
        public void Start()
        {
            Helper.Log("Initialize Magma Plugins", true);
            string path = Path.Combine(Core.SavePath, @"\cfg\Magma\config.cfg");

            if (!File.Exists(path))
            {
                Magma.Data.PATH = Path.Combine(Core.SavePath, @"plugins\");
            }
            else
            {
                Magma.Data.PATH = new IniParser(path).GetSetting("Settings", "Directory");
            }
            Magma.Data.PATH = CommandLine.GetSwitch("-plugindir", Magma.Data.PATH);
            if (!Directory.Exists(Magma.Data.PATH))
            {
                Directory.CreateDirectory(Magma.Data.PATH);
            }
            PluginEngine.GetPluginEngine();
            Magma.Hooks.ServerStarted();
            Helper.Log("Loaded " + PluginEngine.GetPluginEngine().Plugins.Count + " Plugin(s) Total.", true);
        }