private static bool Internal(ConsoleSystem.Arg arg)
    {
        bool flag;

        if (arg.Invalid)
        {
            return(false);
        }
        object obj = Interface.CallHook("IOnServerCommand", arg);

        if (obj as bool)
        {
            return((bool)obj);
        }
        if (!arg.HasPermission())
        {
            arg.ReplyWith("You cannot run this command");
            return(false);
        }
        try
        {
            using (TimeWarning timeWarning = TimeWarning.New(string.Concat("ConsoleSystem: ", arg.cmd.FullName), 0.1f))
            {
                arg.cmd.Call(arg);
            }
            if (arg.cmd.Variable && arg.cmd.GetOveride != null)
            {
                string str  = arg.cmd.String;
                string str1 = (arg.cmd.Variable ? arg.cmd.String : "");
                if (str1 == str)
                {
                    arg.ReplyWith(string.Format("{0}: {1}", arg.cmd.FullName, str.QuoteSafe()));
                }
                else
                {
                    arg.ReplyWith(string.Format("{0}: changed from {1} to {2}", arg.cmd.FullName, str1.QuoteSafe(), str.QuoteSafe()));
                }
            }
            return(true);
        }
        catch (Exception exception1)
        {
            Exception exception = exception1;
            arg.ReplyWith(string.Concat(new string[] { "Error: ", arg.cmd.FullName, " - ", exception.Message, " (", exception.Source, ")" }));
            Debug.LogException(exception);
            flag = false;
        }
        return(flag);
    }
    public static string Run(ConsoleSystem.Option options, string strCommand, params object[] args)
    {
        ConsoleSystem.LastError = null;
        string str = ConsoleSystem.BuildCommand(strCommand, args);

        ConsoleSystem.Arg arg = new ConsoleSystem.Arg(options, str);
        bool flag             = arg.HasPermission();

        if (!arg.Invalid & flag)
        {
            ConsoleSystem.Arg currentArgs = ConsoleSystem.CurrentArgs;
            ConsoleSystem.CurrentArgs = arg;
            bool flag1 = ConsoleSystem.Internal(arg);
            ConsoleSystem.CurrentArgs = currentArgs;
            if (options.PrintOutput & flag1 && arg.Reply != null && arg.Reply.Length > 0)
            {
                DebugEx.Log(arg.Reply, StackTraceLogType.None);
            }
            return(arg.Reply);
        }
        ConsoleSystem.LastError = "Command not found";
        if (!flag)
        {
            ConsoleSystem.LastError = "Permission denied";
        }
        if (options.IsServer || options.ForwardtoServerOnMissing && ConsoleSystem.SendToServer(str))
        {
            if (options.IsServer && options.PrintOutput)
            {
                ConsoleSystem.LastError = string.Concat("Command '", strCommand, "' not found");
                DebugEx.Log(ConsoleSystem.LastError, StackTraceLogType.None);
            }
            return(null);
        }
        ConsoleSystem.LastError = string.Concat("Command '", strCommand, "' not found");
        if (options.PrintOutput)
        {
            DebugEx.Log(ConsoleSystem.LastError, StackTraceLogType.None);
        }
        return(null);
    }