Example #1
0
        public static void RegisterApplication(EntityViewModel viewModel, StreamReader stdOut, StreamReader errOut)
        {
            new Thread(() =>
            {
                while (!stdOut.EndOfStream)
                {
                    string line = stdOut.ReadLine();
                    if (line != null)
                    {
                        ConsoleWriteLine?.Invoke(line, viewModel);
                        if (viewModel is ServerViewModel serverViewModel)
                        {
                            if (line.Contains("For help, type \"help\""))
                            {
                                serverViewModel.CurrentStatus = ServerStatus.RUNNING;
                            }
                            serverViewModel.RoleInputHandler(line);
                        }

                        if (viewModel is NetworkViewModel networkViewModel)
                        {
                            if (waterfallStarted.Match(line).Success)
                            {
                                networkViewModel.CurrentStatus = ServerStatus.RUNNING;
                            }
                        }
                        viewModel.ConsoleOutList.Add(line);
                    }
                }
            }).Start();

            new Thread(() =>
            {
                while (!errOut.EndOfStream)
                {
                    string line = errOut.ReadLine();
                    if (line != null)
                    {
                        // For early minecraft versions
                        if (line.Contains("For help, type \"help\""))
                        {
                            viewModel.CurrentStatus = ServerStatus.RUNNING;
                        }

                        if (viewModel is ServerViewModel serverViewModel)
                        {
                            serverViewModel.RoleInputHandler(line);
                        }
                        ConsoleWriteLine?.Invoke(line, viewModel);
                        viewModel.ConsoleOutList.Add(line);
                    }
                }
            }).Start();
        }
Example #2
0
        public static void RegisterApplication(EntityViewModel viewModel, StreamReader stdOut, StreamReader errOut)
        {
            new Thread(() =>
            {
                while (!stdOut.EndOfStream)
                {
                    string line = stdOut.ReadLine();
                    if (line != null)
                    {
                        ConsoleWriteLine?.Invoke(line, viewModel);

                        if (line.Contains(@"WARN Advanced terminal features are not available in this environment"))
                        {
                            continue;
                        }

                        //bool used to generate green success message in console
                        bool isSuccess = false;
                        if (viewModel is ServerViewModel serverViewModel)
                        {
                            if (line.Contains("For help, type \"help\""))
                            {
                                serverViewModel.CurrentStatus = ServerStatus.RUNNING;
                                isSuccess = true;
                            }
                            serverViewModel.RoleInputHandler(line);
                        }

                        if (viewModel is NetworkViewModel networkViewModel)
                        {
                            if (waterfallStarted.Match(line).Success)
                            {
                                networkViewModel.CurrentStatus = ServerStatus.RUNNING;
                                isSuccess = true;
                            }
                        }

                        viewModel.AddToConsole(isSuccess
                            ? new ConsoleMessage(line, ConsoleMessage.MessageLevel.SUCCESS)
                            : new ConsoleMessage(line));
                    }
                }
            })
            {
                IsBackground = true
            }.Start();