void RegisterCommands()
        {
            const string commandPrefix = "servermetrics";

            ConsoleSystem.Command reloadCfgCommand = new ConsoleSystem.Command()
            {
                Name        = "reloadcfg",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "reloadcfg",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(ReloadCfgCommand)
            };
            ConsoleSystem.Index.Server.Dict[commandPrefix + "." + "reloadcfg"] = reloadCfgCommand;

            ConsoleSystem.Command statusCommand = new ConsoleSystem.Command()
            {
                Name        = "status",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "status",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(StatusCommand)
            };
            ConsoleSystem.Index.Server.Dict[commandPrefix + "." + "status"] = statusCommand;

            ConsoleSystem.Command[] allCommands = ConsoleSystem.Index.All.Concat(new ConsoleSystem.Command[] { reloadCfgCommand, statusCommand }).ToArray();
            // Would be nice if this had a public setter, or better yet, a register command helper
            typeof(ConsoleSystem.Index)
            .GetProperty(nameof(ConsoleSystem.Index.All), System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)
            .SetValue(null, allCommands);
        }
 protected void Awake()
 {
     this.conVar = ConsoleSystem.Index.Client.Find(this.convarName);
     if (this.conVar != null)
     {
         this.UpdateToggleState();
         return;
     }
     Debug.LogWarning(string.Concat("Tweak Toggle Convar Missing: ", this.convarName));
 }
Пример #3
0
 private void cmd_OnValueChanged(ConsoleSystem.Command obj)
 {
     if (!(component == null))
     {
         bool flag = obj.String == on;
         if (component.enabled != flag)
         {
             component.enabled = flag;
         }
     }
 }
Пример #4
0
 protected void Awake()
 {
     Command = ConsoleSystem.Index.Client.Find(ConvarName);
     if (Command == null)
     {
         Command = ConsoleSystem.Index.Server.Find(ConvarName);
     }
     if (Command != null)
     {
         SetState(Command.String == ConvarEnabled);
     }
 }
Пример #5
0
 protected void Awake()
 {
     this.conVar = ConsoleSystem.Index.Client.Find(this.convarName);
     if (this.conVar != null)
     {
         this.UpdateToggleGroup();
     }
     else
     {
         Debug.LogWarning((object)("Tweak Slider Convar Missing: " + this.convarName));
     }
 }
Пример #6
0
 protected void Awake()
 {
     this.conVar = ConsoleSystem.Index.Client.Find(this.convarName);
     if (this.conVar == null)
     {
         Debug.LogWarning((object)("TweakUIDropDown Convar Missing: " + this.convarName));
     }
     else
     {
         this.UpdateState();
     }
 }
Пример #7
0
 public void OnEnable()
 {
     cmd = ConsoleSystem.Index.Client.Find(convar);
     if (cmd == null)
     {
         cmd = ConsoleSystem.Index.Server.Find(convar);
     }
     if (cmd != null)
     {
         cmd.OnValueChanged += cmd_OnValueChanged;
         cmd_OnValueChanged(cmd);
     }
 }
Пример #8
0
 protected void Awake()
 {
     this.Command = ConsoleSystem.Index.Client.Find(this.ConvarName);
     if (this.Command == null)
     {
         this.Command = ConsoleSystem.Index.Server.Find(this.ConvarName);
     }
     if (this.Command == null)
     {
         return;
     }
     this.SetState(this.Command.get_String() == this.ConvarEnabled);
 }
 public void OnEnable()
 {
     this.cmd = ConsoleSystem.Index.Client.Find(this.convar);
     if (this.cmd == null)
     {
         this.cmd = ConsoleSystem.Index.Server.Find(this.convar);
     }
     if (this.cmd == null)
     {
         return;
     }
     this.cmd.OnValueChanged += new Action <ConsoleSystem.Command>(this.cmd_OnValueChanged);
     this.cmd_OnValueChanged(this.cmd);
 }
        private void cmd_OnValueChanged(ConsoleSystem.Command obj)
        {
            if (this.component == null)
            {
                return;
            }
            bool str = obj.String == this.on;

            if (this.component.enabled == str)
            {
                return;
            }
            this.component.enabled = str;
        }
Пример #11
0
        private void cmd_OnValueChanged(ConsoleSystem.Command obj)
        {
            if (Object.op_Equality((Object)this.component, (Object)null))
            {
                return;
            }
            bool flag = obj.get_String() == this.on;

            if (((Behaviour)this.component).get_enabled() == flag)
            {
                return;
            }
            ((Behaviour)this.component).set_enabled(flag);
        }
        internal void BuildCommand(string command)
        {
            if (string.IsNullOrEmpty(command))
            {
                this.Invalid = true;
                return;
            }
            if (command.IndexOf('.') <= 0 || command.IndexOf(' ', 0, command.IndexOf('.')) != -1)
            {
                command = string.Concat("global.", command);
            }
            int num = command.IndexOf('.');

            if (num <= 0)
            {
                return;
            }
            string lower = command.Substring(0, num);

            if (lower.Length < 1)
            {
                return;
            }
            lower = lower.Trim().ToLower();
            string str = command.Substring(num + 1);

            if (str.Length < 1)
            {
                return;
            }
            int num1 = str.IndexOf(' ');

            if (num1 > 0)
            {
                this.FullString = str.Substring(num1 + 1);
                this.FullString = this.FullString.Trim();
                this.Args       = this.FullString.SplitQuotesStrings();
                str             = str.Substring(0, num1);
            }
            str = str.Trim().ToLower();
            if (this.cmd == null && this.Option.IsClient)
            {
                this.cmd = ConsoleSystem.Index.Client.Find(string.Concat(lower, ".", str));
            }
            if (this.cmd == null && this.Option.IsServer)
            {
                this.cmd = ConsoleSystem.Index.Server.Find(string.Concat(lower, ".", str));
            }
            this.Invalid = this.cmd == null;
        }
Пример #13
0
 public ConsoleCommand(string name)
 {
     Name = name;
     string[] splitName = Name.Split('.');
     RustCommand = new ConsoleSystem.Command
     {
         Name        = splitName[1],
         Parent      = splitName[0],
         FullName    = name,
         ServerUser  = true,
         ServerAdmin = true,
         Client      = true,
         ClientInfo  = false,
         Variable    = false,
         Call        = HandleCommand
     };
 }
Пример #14
0
 public ConsoleCommand(string name)
 {
     Name = name;
     var split_name = Name.Split('.');
     RustCommand = new ConsoleSystem.Command
     {
         name = split_name[1],
         parent = split_name[0],
         namefull = name,
         isCommand = true,
         isUser = true,
         isAdmin = true,
         GetString = ReturnEmptyString,
         SetString = DoNothing,
         Call = HandleCommand
     };
 }
Пример #15
0
 public ConsoleCommand(string name)
 {
     this.Name = name;
     string[] strArray = this.Name.Split(new Char[] { '.' });
     this.RustCommand = new ConsoleSystem.Command()
     {
         Name        = strArray[1],
         Parent      = strArray[0],
         FullName    = name,
         ServerUser  = true,
         ServerAdmin = true,
         Client      = true,
         ClientInfo  = false,
         Variable    = false,
         Call        = new Action <ConsoleSystem.Arg>(this.HandleCommand)
     };
 }
Пример #16
0
            public ConsoleCommand(string name)
            {
                Name = name;
                var splitName = Name.Split('.');

                RustCommand = new ConsoleSystem.Command
                {
                    name      = splitName[1],
                    parent    = splitName[0],
                    namefull  = name,
                    isCommand = true,
                    isUser    = true,
                    isAdmin   = true,
                    GetString = ReturnEmptyString,
                    SetString = DoNothing,
                    Call      = HandleCommand
                };
            }
 public static void Initialize(ConsoleSystem.Command[] Commands)
 {
     ConsoleSystem.Index.All         = Commands;
     ConsoleSystem.Index.Server.Dict = new Dictionary <string, ConsoleSystem.Command>();
     ConsoleSystem.Index.Client.Dict = new Dictionary <string, ConsoleSystem.Command>();
     ConsoleSystem.Command[] all = ConsoleSystem.Index.All;
     for (int i = 0; i < (int)all.Length; i++)
     {
         ConsoleSystem.Command command = all[i];
         if (command.Server)
         {
             if (!ConsoleSystem.Index.Server.Dict.ContainsKey(command.FullName))
             {
                 ConsoleSystem.Index.Server.Dict.Add(command.FullName, command);
             }
             else
             {
                 Debug.LogWarning(string.Concat("Server Vars have multiple entries for ", command.FullName));
             }
             if (command.Parent != "global" && !ConsoleSystem.Index.Server.GlobalDict.ContainsKey(command.Name))
             {
                 ConsoleSystem.Index.Server.GlobalDict.Add(command.Name, command);
             }
         }
         if (command.Client)
         {
             if (!ConsoleSystem.Index.Client.Dict.ContainsKey(command.FullName))
             {
                 ConsoleSystem.Index.Client.Dict.Add(command.FullName, command);
             }
             else
             {
                 Debug.LogWarning(string.Concat("Client Vars have multiple entries for ", command.FullName));
             }
             if (command.Parent != "global" && !ConsoleSystem.Index.Client.GlobalDict.ContainsKey(command.Name))
             {
                 ConsoleSystem.Index.Client.GlobalDict.Add(command.Name, command);
             }
         }
     }
     Facepunch.Input.RunBind += new Action <string, bool>((string strCommand, bool pressed) => ConsoleSystem.Run(ConsoleSystem.Option.Client, string.Format("{0} {1}", strCommand, pressed), Array.Empty <object>()));
 }
 internal bool CanSeeInFind(ConsoleSystem.Command command)
 {
     if (command == null)
     {
         return(false);
     }
     if (this.Option.IsUnrestricted)
     {
         return(true);
     }
     if (this.IsClientside)
     {
         return(command.Client);
     }
     if (!this.IsServerside)
     {
         return(false);
     }
     return(command.Server);
 }
Пример #19
0
        void RegisterCommands()
        {
            const string commandPrefix = "adminrestrictions";

            ConsoleSystem.Command reloadCfgCommand = new ConsoleSystem.Command()
            {
                Name        = "reloadcfg",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "reloadcfg",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(ReloadCfgCommand)
            };
            ConsoleSystem.Index.Server.Dict[reloadCfgCommand.FullName] = reloadCfgCommand;

            ConsoleSystem.Command addGloballyAllowedCommand = new ConsoleSystem.Command()
            {
                Name        = "addgloballyallowedcommand",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "addgloballyallowedcommand",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(AddGloballyAllowedCommand)
            };
            ConsoleSystem.Index.Server.Dict[addGloballyAllowedCommand.FullName] = addGloballyAllowedCommand;

            ConsoleSystem.Command removeGloballyAllowedCommand = new ConsoleSystem.Command()
            {
                Name        = "removegloballyallowedcommand",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "removegloballyallowedcommand",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(RemoveGloballyAllowedCommand)
            };
            ConsoleSystem.Index.Server.Dict[removeGloballyAllowedCommand.FullName] = removeGloballyAllowedCommand;

            ConsoleSystem.Command addGloballyBlockedCommand = new ConsoleSystem.Command()
            {
                Name        = "addgloballyblockedcommand",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "addgloballyblockedcommand",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(AddGloballyBlockedCommand)
            };
            ConsoleSystem.Index.Server.Dict[addGloballyBlockedCommand.FullName] = addGloballyBlockedCommand;

            ConsoleSystem.Command removeGloballyBlockedCommand = new ConsoleSystem.Command()
            {
                Name        = "removegloballyblockedcommand",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "removegloballyblockedcommand",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(RemoveGloballyBlockedCommand)
            };
            ConsoleSystem.Index.Server.Dict[removeGloballyBlockedCommand.FullName] = removeGloballyBlockedCommand;

            ConsoleSystem.Command addAdminToGroupCommand = new ConsoleSystem.Command()
            {
                Name        = "addadmintogroup",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "addadmintogroup",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(AddAdminToGroupCommand)
            };
            ConsoleSystem.Index.Server.Dict[addAdminToGroupCommand.FullName] = addAdminToGroupCommand;

            ConsoleSystem.Command removeAdminFromGroupCommand = new ConsoleSystem.Command()
            {
                Name        = "removeadminfromgroup",
                Parent      = commandPrefix,
                FullName    = commandPrefix + "." + "removeadminfromgroup",
                ServerAdmin = true,
                Variable    = false,
                Call        = new Action <ConsoleSystem.Arg>(RemoveAdminFromGroupCommand)
            };
            ConsoleSystem.Index.Server.Dict[removeAdminFromGroupCommand.FullName] = removeAdminFromGroupCommand;

            ConsoleSystem.Command[] allCommands = ConsoleSystem.Index.All.Concat(new ConsoleSystem.Command[] { reloadCfgCommand, addAdminToGroupCommand, removeAdminFromGroupCommand }).ToArray();
            // Would be nice if this had a public setter, or better yet, a register command helper
            typeof(ConsoleSystem.Index)
            .GetProperty(nameof(ConsoleSystem.Index.All), System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)
            .SetValue(null, allCommands);
        }