Пример #1
0
        public static void ConsoleReceived(ref ConsoleSystem.Arg arg, bool external)
        {
            string clss        = arg.Class.ToLower();
            string func        = arg.Function.ToLower();
            string name        = "RCON_External";
            bool   adminRights = external;

            if (!external)
            {
                //Fougerite.Player player = Fougerite.Player.FindByPlayerClient (arg.argUser.playerClient);
                Fougerite.Player player = Fougerite.Server.Cache[arg.argUser.playerClient.userID];
                if (player.Admin)
                {
                    adminRights = true;
                }
                name = player.Name;
            }
            if (adminRights)
            {
                if (clss == "lua" && func == "reload" && arg.ArgsStr == "")
                {
                    LuaModule.GetInstance().ReloadPlugins();
                    arg.ReplyWith("Lua Reloaded!");
                    Logger.LogDebug("[MoonSharp] " + name + " executed: lua.reload");
                }
                else if (clss == "lua" && func == "load")
                {
                    LuaModule.GetInstance().LoadPlugin(arg.ArgsStr);
                    arg.ReplyWith("Lua.load plugin executed!");
                    Logger.LogDebug("[MoonSharp] " + name + " executed: lua.load " + arg.ArgsStr);
                }
                else if (clss == "lua" && func == "unload")
                {
                    LuaModule.GetInstance().UnloadPlugin(arg.ArgsStr);
                    arg.ReplyWith("Lua.unload plugin executed!");
                    Logger.LogDebug("[MoonSharp] " + name + " executed: lua.unload " + arg.ArgsStr);
                }
                else if (clss == "lua" && func == "reload")
                {
                    LuaModule.GetInstance().ReloadPlugin(arg.ArgsStr);
                    arg.ReplyWith("Lua.reload plugin executed!");
                    Logger.LogDebug("[MoonSharp] " + name + " executed: lua.reload " + arg.ArgsStr);
                }
            }

            if (OnConsoleReceived != null)
            {
                OnConsoleReceived(ref arg, external);
            }
        }
Пример #2
0
 public override void Initialize()
 {
     pluginDirectory = new DirectoryInfo(ModuleFolder);
     if (!Directory.Exists(pluginDirectory.FullName))
     {
         Directory.CreateDirectory(pluginDirectory.FullName);
     }
     MoonSharp.Interpreter.UserData.RegisterType <Fougerite.Util>();
     MoonSharp.Interpreter.UserData.RegisterType <Fougerite.Server>();
     MoonSharp.Interpreter.UserData.RegisterType <Fougerite.DataStore>();
     MoonSharp.Interpreter.UserData.RegisterType <Fougerite.Data>();
     MoonSharp.Interpreter.UserData.RegisterType <Fougerite.Web>();
     MoonSharp.Interpreter.UserData.RegisterType <Fougerite.World>();
     MoonSharp.Interpreter.UserData.RegisterType <Fougerite.Events.CraftingEvent>();
     MoonSharp.Interpreter.UserData.RegisterType <LuaPlugin>();
     MoonSharp.Interpreter.UserData.RegisterType <MoonSharpTE>();
     plugins = new Dictionary <string, LuaPlugin>();
     ReloadPlugins();
     Hooks.OnConsoleReceived += new Hooks.ConsoleHandlerDelegate(ConsoleReceived);
     if (instance == null)
     {
         instance = this;
     }
 }