コード例 #1
0
ファイル: Hooks.cs プロジェクト: balu92/Fougerite
        public static bool ConsoleReceived(ref ConsoleSystem.Arg a)
        {
            Contract.Assume(a != null);
            Contract.Assume(a.Class != null);
            Contract.Assume(a.Function != null);

            try
            {
                bool external    = a.argUser == null;
                bool adminRights = (a.argUser != null && a.argUser.admin) || external;

                if ((a.Class.ToLower() == "fougerite") && (a.Function.ToLower() == "reload"))
                {
                    if (adminRights)
                    {
                        ModuleManager.ReloadModules();
                        a.ReplyWith("Fougerite: Reloaded!");
                    }
                }
                else if (OnConsoleReceived != null)
                {
                    OnConsoleReceived(ref a, external);
                }

                if (string.IsNullOrEmpty(a.Reply))
                {
                    a.ReplyWith("Fougerite: " + a.Class + "." + a.Function + " was executed!");
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(false);
        }
コード例 #2
0
ファイル: Hooks.cs プロジェクト: slavagmail/Fougerite
        public static bool ConsoleReceived(ref ConsoleSystem.Arg a)
        {
            StringComparison ic          = StringComparison.InvariantCultureIgnoreCase;
            bool             external    = a.argUser == null;
            bool             adminRights = (a.argUser != null && a.argUser.admin) || external;

            string userid = "[external][external]";

            if (adminRights && !external)
            {
                userid = string.Format("[{0}][{1}]", a.argUser.displayName, a.argUser.userID.ToString());
            }

            string logmsg = string.Format("[ConsoleReceived] userid={0} adminRights={1} command={2}.{3} args={4}", userid, adminRights.ToString(), a.Class, a.Function, (a.HasArgs(1) ? a.ArgsStr : "none"));

            Logger.LogDebug(logmsg);

            if (a.Class.Equals("fougerite", ic) && a.Function.Equals("reload", ic))
            {
                if (adminRights)
                {
                    ModuleManager.ReloadModules();
                    a.ReplyWith("Fougerite: Reloaded!");
                }
            }
            else if (a.Class.Equals("fougerite", ic) && a.Function.Equals("save", ic))
            {
                AvatarSaveProc.SaveAll();
                ServerSaveManager.AutoSave();
                if (Fougerite.Server.GetServer().HasRustPP)
                {
                    Fougerite.Server.GetServer().GetRustPPAPI().RustPPSave();
                }
                DataStore.GetInstance().Save();
                a.ReplyWith("Fougerite: Saved!");
            }
            else if (a.Class.Equals("fougerite", ic) && a.Function.Equals("rustpp", ic))
            {
                foreach (var module in Fougerite.ModuleManager.Modules)
                {
                    if (module.Plugin.Name.Equals("RustPPModule"))
                    {
                        module.DeInitialize();
                        module.Initialize();
                        break;
                    }
                }
                a.ReplyWith("Rust++ Reloaded!");
            }
            else if (OnConsoleReceived != null)
            {
                OnConsoleReceived(ref a, external);
            }

            if (string.IsNullOrEmpty(a.Reply))
            {
                a.ReplyWith(string.Format("Fougerite: {0}.{1} was executed!", a.Class, a.Function));
            }

            return(true);
        }