From 663d617ef63eb2544171ae447ca414b7b2a60c4a Mon Sep 17 00:00:00 2001 From: ORelio Date: Sun, 18 Apr 2021 18:44:02 +0200 Subject: [PATCH] OnDisconnect: Call AutoRelog last (#1517) Call AutoRelog last to leave other bots time to perform cleanup --- MinecraftClient/McClient.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs index fe24eadf..f875f959 100644 --- a/MinecraftClient/McClient.cs +++ b/MinecraftClient/McClient.cs @@ -531,7 +531,11 @@ namespace MinecraftClient throw new InvalidOperationException(Translations.Get("exception.user_logout")); } - foreach (ChatBot bot in bots.ToArray()) + //Process AutoRelog last to make sure other bots can perform their cleanup tasks first (issue #1517) + List onDisconnectBotList = bots.Where(bot => !(bot is AutoRelog)).ToList(); + onDisconnectBotList.AddRange(bots.Where(bot => bot is AutoRelog)); + + foreach (ChatBot bot in onDisconnectBotList) { try {