private void HandleMessage(string text, OutputParseResult outputParseResult)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker) (() => HandleMessage(text, outputParseResult)));
            }
            else
            {
                string[] content =
                {
                    (slvIssues.Items.Count + 1).ToString(),
                    outputParseResult.Type.ToString(),
                    outputParseResult.Time.ToLongTimeString(),
                    Regex.Replace(outputParseResult.Message, "^\\[(warn|warning|severe|error)\\]\\s?", "", RegexOptions.IgnoreCase)
                };
                ListViewItem lvi = new ListViewItem(content) {Tag = outputParseResult};
                switch (outputParseResult.Type)
                {
                    case MessageType.Warning:
                        lvi.ForeColor = ConsoleTab.Reference.MCCOut.MessageColorWarning;
                        break;
                    default:
                        lvi.ForeColor = ConsoleTab.Reference.MCCOut.MessageColorSevere;
                        break;
                }

                slvIssues.Items.Add(lvi);
            }
        }
		private static void RaiseOutputParsedEvent(string text, OutputParseResult outputParseResult)
		{
			OutputParsedEventHandler handler = OutputParsed;
			if (handler != null)
			{
				handler(text, outputParseResult);
			}
		}
		private static void RaiseWarningMessageReceivedEvent(string text, OutputParseResult outputParseResult)
		{
			OutputParsedEventHandler handler = WarningMessageReceived;
			if (handler != null)
			{
				handler(text, outputParseResult);
			}
		}
Exemple #4
0
        private static void RaiseOutputParsedEvent(string text, OutputParseResult outputParseResult)
        {
            OutputParsedEventHandler handler = OutputParsed;

            if (handler != null)
            {
                handler(text, outputParseResult);
            }
        }
Exemple #5
0
        private static void RaiseSevereMessageReceivedEvent(string text, OutputParseResult outputParseResult)
        {
            OutputParsedEventHandler handler = SevereMessageReceived;

            if (handler != null)
            {
                handler(text, outputParseResult);
            }
        }
Exemple #6
0
        private static void RaisePlayerIpBanEvent(string text, OutputParseResult outputParseResult,
                                                  IPlayerAction playerAction)
        {
            PlayerEventHandler handler = PlayerIpBan;

            if (handler != null)
            {
                handler(text, outputParseResult, playerAction);
            }
        }
Exemple #7
0
        /// <summary>
        ///     Raise an event notifying the system about a received /list command
        /// </summary>
        /// <param name="text">The text that was received</param>
        /// <param name="outputParseResult">The parse result</param>
        /// <param name="players">Dictionary containing the player names as key, the names with their prefixes as value</param>
        private static void RaisePlayerListReceivedEvent(string text, OutputParseResult outputParseResult,
                                                         Dictionary <String, String> players)
        {
            PlayerListReceivedEventHandler handler = PlayerListReceived;

            if (handler != null)
            {
                handler(text, outputParseResult, players);
            }
        }
		private void OnOutputReceived(string s, OutputParseResult result)
		{
			try
			{
				if (Regex.IsMatch(result.Message, Parameters)) OnTaskerTriggerFired();
			}
			catch (Exception exception)
			{
				Disable(); // prevent spam of this error on server start
				MetroMessageBox.Show(Application.OpenForms[0],
					"Failed to execute regex trigger!" + Environment.NewLine + "Following regex caused issues: " +
					Parameters +
					Environment.NewLine + "The trigger will now be disabled. Edit the task to enable it again.",
					"Regex trigger failed",
					MessageBoxButtons.OK, MessageBoxIcon.Error);
				Logger.Log(LogLevel.Warning, "Regex trigger failed, check regex!", exception.Message);
			}
		}
Exemple #9
0
		private void HandleMessage(string text, OutputParseResult outputParseResult)
		{
			if (InvokeRequired)
			{
				Invoke((MethodInvoker) (() => HandleMessage(text, outputParseResult)));
			}
			else
			{
				string[] content =
				{
					(++_issueCount).ToString(),
					outputParseResult.Type.ToString(),
					outputParseResult.Time.ToLongTimeString(),
					Regex.Replace(outputParseResult.Message, "^\\[(warn|warning|severe|error)\\]\\s?", "", RegexOptions.IgnoreCase)
				};
				ListViewItem lvi = new ListViewItem(content) {Tag = outputParseResult};
				switch (outputParseResult.Type)
				{
					case MessageType.Warning:
						lvi.ForeColor = ConsoleTab.Reference.MCCOut.MessageColorWarning;
						break;
					default:
						lvi.ForeColor = ConsoleTab.Reference.MCCOut.MessageColorSevere;
						break;
				}
				
				slvIssues.Items.Add(lvi);
				if (slvIssues.Items.Count > 1023)
				{
					// when too much entries, leave only 512 entries
					foreach (ListViewItem item in slvIssues.Items)
					{
						if (ulong.Parse(item.SubItems[0].Text) < _issueCount-512 )
						{
							item.Remove();
						}
					}
				}
			}
		}
		private void OnOutputReceived(string s, OutputParseResult result)
		{
			if (result.Message.ToLower().Contains(result.Message.ToLower())) OnTaskerTriggerFired();
		}
Exemple #11
0
		/// <summary>
		///     Print output to the console
		/// </summary>
		/// <param name="text"></param>
		/// <param name="outputParseResult"></param>
		private void PrintOutput(string text, OutputParseResult outputParseResult)
		{
			MCCOut.WriteOutput(outputParseResult.Type, outputParseResult.Message);
		}
Exemple #12
0
 /// <summary>
 ///     Handle output from the server and print it to the bottom of the screen
 /// </summary>
 /// <param name="text"> The text that was parsed</param>
 /// <param name="result">Result of the parse operation</param>
 private void HandleOutput(string text, OutputParseResult result)
 {
     //suport for calls from other threads
     if (InvokeRequired)
     {
         Invoke((MethodInvoker) (() => HandleOutput(text, result)));
     }
     else
     {
         LblToolsMainServerOutput.Text = result.Message;
     }
 }
Exemple #13
0
		/// <summary>
		///     Play the severe message sound
		/// </summary>
		private void SoundSevereMessage(string text, OutputParseResult outputParseResult)
		{
			new Audio().Play(Resources.sound_severe, AudioPlayMode.Background);
		}
Exemple #14
0
		private void ShowBanTray(string text, OutputParseResult outputParseResult,
			IPlayerAction playerAction)
		{
			if (!_alwaysShowBalloons && MainForm.Reference.Visible)
				return; // if visible and balloons shouldn't be shown always, don't show.

			_icon.ShowBalloonTip(BalloonDuration,
				playerAction.PlayerName + " " + Locale.Tr("was banned from the server"),
				outputParseResult.Message, ToolTipIcon.Warning);
		}
		private static void RaisePlayerIpBanEvent(string text, OutputParseResult outputParseResult,
			IPlayerAction playerAction)
		{
			PlayerEventHandler handler = PlayerIpBan;
			if (handler != null)
			{
				handler(text, outputParseResult, playerAction);
			}
		}
		/// <summary>
		///     Raise an event notifying the system about a received /list command
		/// </summary>
		/// <param name="text">The text that was received</param>
		/// <param name="outputParseResult">The parse result</param>
		/// <param name="players">Dictionary containing the player names as key, the names with their prefixes as value</param>
		private static void RaisePlayerListReceivedEvent(string text, OutputParseResult outputParseResult,
		Dictionary<String,String> players)
		{
			PlayerListReceivedEventHandler handler = PlayerListReceived;
			if (handler != null)
			{
				handler(text, outputParseResult, players);
			}
		}
Exemple #17
0
		/// <summary>
		///     Play the warning message sound
		/// </summary>
		private void SoundWarningMessage(string text, OutputParseResult outputParseResult)
		{
			new Audio().Play(Resources.sound_warning, AudioPlayMode.Background);
		}
		private static void RaiseJavaStackStraceMessageReceivedEvent(string text, OutputParseResult outputParseResult)
		{
			OutputParsedEventHandler handler = JavaStackStraceMessageReceived;
			if (handler != null)
			{
				handler(text, outputParseResult);
			}
		}
Exemple #19
0
		/// <summary>
		///     Play the player left sound
		/// </summary>
		private void SoundPlayerLeave(string text, OutputParseResult outputParseResult, IPlayerAction playerAction)
		{
			new Audio().Play(Resources.sound_disconnect, AudioPlayMode.Background);
		}
Exemple #20
0
        /// <summary>
        ///     Handle server output, raise all events that should be raised
        /// </summary>
        /// <param name="text">output text to handle</param>
        /// <param name="server">the server that should handle the output</param>
        /// <param name="fromStandardErrorOut">Is this message received on the error stream?</param>
        public static void HandleOutput(IMinecraftServer server, string text, Boolean fromStandardErrorOut = false)
        {
            RaiseOutputReceivedEvent(text);

            OutputParseResult result = server.ParseOutput(text);

            if (result == null)
            {
                return;
            }

            RaiseOutputParsedEvent(text, result);

            switch (result.Type)
            {
            case MessageType.Info:
                RaiseInfoMessageReceivedEvent(text, result);

                // detect an issued stop command (so the GUI knows this isn't a crash)
                if (result.Message == "[INFO] Stopping server" || result.Message == "[INFO] Stopping the server")
                {
                    ProcessHandler.ProcessHandler.MarkServerAsStopping();
                }

                break;

            case MessageType.Warning:
                RaiseWarningMessageReceivedEvent(text, result);
                CheckErrorCause(result.Message);
                //failed to bind to port comes on standardout, so we need to check anyway
                break;

            case MessageType.Severe:
                RaiseSevereMessageReceivedEvent(text, result);
                CheckErrorCause(result.Message);
                break;

            case MessageType.JavaStackTrace:
                RaiseJavaStackStraceMessageReceivedEvent(text, result);
                if (fromStandardErrorOut)
                {
                    CheckErrorCause(result.Message);
                }
                break;

            case MessageType.JavaStatus:
                RaiseJavaStatusMessageReceivedEvent(text, result);
                if (fromStandardErrorOut)
                {
                    CheckErrorCause(result.Message);
                }
                break;

            case MessageType.PlayerJoin:
                RaisePlayerJoinEvent(text, result, result.Action);
                break;

            case MessageType.PlayerLeave:
                RaisePlayerLeaveEvent(text, result, result.Action);
                break;

            case MessageType.PlayerKick:
                RaisePlayerKickEvent(text, result, result.Action);
                break;

            case MessageType.PlayerBan:
                RaisePlayerBanEvent(text, result, result.Action);
                break;

            case MessageType.PlayerIpBan:
                RaisePlayerIpBanEvent(text, result, result.Action);
                break;

            case MessageType.PlayerList:
                RaisePlayerListReceivedEvent(text, result, new Dictionary <string, string>());
                break;

            default:
                RaiseUnknownMessageReceivedEvent(text, result);
                if (fromStandardErrorOut)
                {
                    CheckErrorCause(result.Message);
                }
                break;
            }
        }
		/// <summary>
		///     Got an answer, reset the "waiting for heartbeat" variable
		/// </summary>
		/// <param name="text"></param>
		/// <param name="outputParseResult"></param>
		/// <param name="playersDictionary"></param>
		private void heartbeat_received(string text, OutputParseResult outputParseResult,
			Dictionary<string, string> playersDictionary)
		{
			_heartbeat_unanswered = false;
		}
		/// <summary>
		///     Handle a player disconnect event
		/// </summary>
		private static void HandlePlayerDisconnect(string text, OutputParseResult outputParseResult,
			IPlayerAction playeraction)
		{
			Player player = GetOnlinePlayerByName(playeraction.PlayerName);
			if (player != null) RemovePlayer(player);
		}
		/// <summary>
		///     Handle a player join event
		/// </summary>
		private static void HandlePlayerJoin(
			string text,
			OutputParseResult outputparseresult,
			IPlayerAction playeraction)
		{
			PlayerActionJoin join = (PlayerActionJoin) playeraction;

			Player player = new Player(join.PlayerName, join.Ip, join.PlayerName);

			AddPlayer(player);
		}