Chat Format: increase priority of custom regex

If a custom regex is defined in config, process it first.
Previous behavior was to process builtins first.
Should reduce issues with custom regex and builtins=true
This commit is contained in:
ORelio 2019-04-17 05:32:31 +02:00
parent 2ebc8eded5
commit 80d51ede31

View file

@ -241,6 +241,18 @@ namespace MinecraftClient
text = GetVerbatim(text);
//User-defined regex for private chat messages
if (Settings.ChatFormat_Private != null)
{
Match regexMatch = Settings.ChatFormat_Private.Match(text);
if (regexMatch.Success && regexMatch.Groups.Count >= 3)
{
sender = regexMatch.Groups[1].Value;
message = regexMatch.Groups[2].Value;
return IsValidName(sender);
}
}
//Built-in detection routine for private messages
if (Settings.ChatFormat_Builtins)
{
@ -323,18 +335,6 @@ namespace MinecraftClient
catch (ArgumentOutOfRangeException) { /* Same here */ }
}
//User-defined regex for private chat messages
if (Settings.ChatFormat_Private != null)
{
Match regexMatch = Settings.ChatFormat_Private.Match(text);
if (regexMatch.Success && regexMatch.Groups.Count >= 3)
{
sender = regexMatch.Groups[1].Value;
message = regexMatch.Groups[2].Value;
return IsValidName(sender);
}
}
return false;
}
@ -351,7 +351,19 @@ namespace MinecraftClient
return false;
text = GetVerbatim(text);
//User-defined regex for public chat messages
if (Settings.ChatFormat_Public != null)
{
Match regexMatch = Settings.ChatFormat_Public.Match(text);
if (regexMatch.Success && regexMatch.Groups.Count >= 3)
{
sender = regexMatch.Groups[1].Value;
message = regexMatch.Groups[2].Value;
return IsValidName(sender);
}
}
//Built-in detection routine for public messages
if (Settings.ChatFormat_Builtins)
{
@ -427,18 +439,6 @@ namespace MinecraftClient
}
}
//User-defined regex for public chat messages
if (Settings.ChatFormat_Public != null)
{
Match regexMatch = Settings.ChatFormat_Public.Match(text);
if (regexMatch.Success && regexMatch.Groups.Count >= 3)
{
sender = regexMatch.Groups[1].Value;
message = regexMatch.Groups[2].Value;
return IsValidName(sender);
}
}
return false;
}
@ -455,6 +455,17 @@ namespace MinecraftClient
text = GetVerbatim(text);
//User-defined regex for teleport requests
if (Settings.ChatFormat_TeleportRequest != null)
{
Match regexMatch = Settings.ChatFormat_TeleportRequest.Match(text);
if (regexMatch.Success && regexMatch.Groups.Count >= 2)
{
sender = regexMatch.Groups[1].Value;
return IsValidName(sender);
}
}
//Built-in detection routine for teleport requests
if (Settings.ChatFormat_Builtins)
{
@ -484,17 +495,6 @@ namespace MinecraftClient
}
}
//User-defined regex for teleport requests
if (Settings.ChatFormat_TeleportRequest != null)
{
Match regexMatch = Settings.ChatFormat_TeleportRequest.Match(text);
if (regexMatch.Success && regexMatch.Groups.Count >= 2)
{
sender = regexMatch.Groups[1].Value;
return IsValidName(sender);
}
}
return false;
}