mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Catch exceptions for bots for onTextReceived
Avoid crashing due to bots not properly processing text
This commit is contained in:
parent
c30d3025f7
commit
aaced855d8
1 changed files with 16 additions and 3 deletions
|
|
@ -305,8 +305,21 @@ namespace MinecraftClient
|
|||
public void OnTextReceived(string text)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(text, false);
|
||||
foreach (ChatBot bot in new List<ChatBot>(bots))
|
||||
bot.GetText(text);
|
||||
for (int i = 0; i < bots.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
bots[i].GetText(text);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (!(e is ThreadAbortException))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8GetText: Got error from " + bots[i].ToString() + ": " + e.ToString());
|
||||
}
|
||||
else throw; //ThreadAbortException should not be caught
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -357,7 +370,7 @@ namespace MinecraftClient
|
|||
{
|
||||
if (!(e is ThreadAbortException))
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted("§8Got error from " + bots[i].ToString() + ": " + e.ToString());
|
||||
ConsoleIO.WriteLineFormatted("§8Update: Got error from " + bots[i].ToString() + ": " + e.ToString());
|
||||
}
|
||||
else throw; //ThreadAbortException should not be caught
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue